{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/comments/40490940","id":40490940,"diff_hunk":"@@ -85,14 +89,67 @@ public void doIndex(StaplerRequest req, StaplerResponse resp) {\n             return;\n         }\n \n-        for (GhprbWebHook webHook : getWebHooks()) {\n-            try {\n-                webHook.handleWebHook(event, payload, body, signature);\n-            } catch (Exception e) {\n-                logger.log(Level.SEVERE, \"Unable to process web hook for: \" + webHook.getProjectName(), e);\n+        logger.log(Level.FINE, \"Got payload event: {0}\", event);\n+        \n+        try {\n+            GitHub gh = GitHub.connectAnonymously();\n+            \n+            if (\"issue_comment\".equals(event)) {\n+                IssueComment issueComment = getIssueComment(payload, gh);\n+                GHIssueState state = issueComment.getIssue().getState();\n+                if (state == GHIssueState.CLOSED) {\n+                    logger.log(Level.INFO, \"Skip comment on closed PR\");\n+                    return;\n+                }\n+                \n+                String repoName = issueComment.getRepository().getFullName();\n+\n+                logger.log(Level.INFO, \"Checking issue comment ''{0}'' for repo {1}\", new Object[] { issueComment.getComment(), repoName });\n+\n+                for (GhprbWebHook webHook : getWebHooks()) {\n+                    try {\n+                        if (webHook.matchRepo(repoName) && webHook.checkSignature(body, signature)) {\n+                            IssueComment authedComment = getIssueComment(payload, webHook.getGitHub());\n+                            webHook.handleComment(authedComment);\n+                        }\n+                    } catch (Exception e) {\n+                        logger.log(Level.SEVERE, \"Unable to process web hook for: \" + webHook.getProjectName(), e);\n+                    }\n+                }\n+\n+            } else if (\"pull_request\".equals(event)) {\n+                PullRequest pr = getPullRequest(payload, gh);\n+                String repoName = pr.getRepository().getFullName();\n+\n+                logger.log(Level.INFO, \"Checking PR #{1} for {0}\", new Object[] { repoName, pr.getNumber() });\n+\n+                for (GhprbWebHook webHook : getWebHooks()) {\n+                    try {\n+                        if (webHook.matchRepo(repoName) && webHook.checkSignature(body, signature)) {\n+                            PullRequest authedPr = getPullRequest(payload, webHook.getGitHub());\n+                            webHook.handlePR(authedPr);\n+                        }\n+                    } catch (Exception e) {\n+                        logger.log(Level.SEVERE, \"Unable to process web hook for: \" + webHook.getProjectName(), e);\n+                    }\n+                }\n+            } else {\n+                logger.log(Level.WARNING, \"Request not known\");\n             }\n+\n+        } catch (IOException e) {\n+            logger.log(Level.SEVERE, \"Unable to connect to GitHub anonymously\", e);\n         }\n-        \n+    }\n+    \n+    private PullRequest getPullRequest(String payload, GitHub gh) throws IOException {","path":"src/main/java/org/jenkinsci/plugins/ghprb/GhprbRootAction.java","position":74,"original_position":74,"commit_id":"f34aaa41b2044193f54aff9d434643728f8b0ac1","original_commit_id":"f34aaa41b2044193f54aff9d434643728f8b0ac1","user":{"login":"arcivanov","id":5355666,"avatar_url":"https://avatars.githubusercontent.com/u/5355666?v=3","gravatar_id":"","url":"https://api.github.com/users/arcivanov","html_url":"https://github.com/arcivanov","followers_url":"https://api.github.com/users/arcivanov/followers","following_url":"https://api.github.com/users/arcivanov/following{/other_user}","gists_url":"https://api.github.com/users/arcivanov/gists{/gist_id}","starred_url":"https://api.github.com/users/arcivanov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcivanov/subscriptions","organizations_url":"https://api.github.com/users/arcivanov/orgs","repos_url":"https://api.github.com/users/arcivanov/repos","events_url":"https://api.github.com/users/arcivanov/events{/privacy}","received_events_url":"https://api.github.com/users/arcivanov/received_events","type":"User","site_admin":false},"body":"so you restored your cleanup and ensured that payload parsing is done via webHook's GitHub?","created_at":"2015-09-26T06:54:40Z","updated_at":"2015-09-26T06:54:40Z","html_url":"https://github.com/jenkinsci/ghprb-plugin/pull/202#discussion_r40490940","pull_request_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/comments/40490940"},"html":{"href":"https://github.com/jenkinsci/ghprb-plugin/pull/202#discussion_r40490940"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202","id":46076627,"html_url":"https://github.com/jenkinsci/ghprb-plugin/pull/202","diff_url":"https://github.com/jenkinsci/ghprb-plugin/pull/202.diff","patch_url":"https://github.com/jenkinsci/ghprb-plugin/pull/202.patch","issue_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/202","number":202,"state":"open","locked":false,"title":"Fix issues with authentication for hooks.","user":{"login":"DavidTanner","id":368889,"avatar_url":"https://avatars.githubusercontent.com/u/368889?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidTanner","html_url":"https://github.com/DavidTanner","followers_url":"https://api.github.com/users/DavidTanner/followers","following_url":"https://api.github.com/users/DavidTanner/following{/other_user}","gists_url":"https://api.github.com/users/DavidTanner/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidTanner/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidTanner/subscriptions","organizations_url":"https://api.github.com/users/DavidTanner/orgs","repos_url":"https://api.github.com/users/DavidTanner/repos","events_url":"https://api.github.com/users/DavidTanner/events{/privacy}","received_events_url":"https://api.github.com/users/DavidTanner/received_events","type":"User","site_admin":false},"body":"Change should address #199 and #198.\r\n\r\nEvents will be parsed once to get the repo, then again before passing down to any relevant jobs.  This allows for authenticating as needed for relevant jobs.","created_at":"2015-09-26T06:28:38Z","updated_at":"2015-09-26T06:54:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d3a9b102c3e4a97ccb66ce9154c46a437e0244eb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/202/comments","statuses_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/statuses/f34aaa41b2044193f54aff9d434643728f8b0ac1","head":{"label":"jenkinsci:webhook","ref":"webhook","sha":"f34aaa41b2044193f54aff9d434643728f8b0ac1","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":5672873,"name":"ghprb-plugin","full_name":"jenkinsci/ghprb-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/ghprb-plugin","description":"github pull requests builder plugin for Jenkins","fork":true,"url":"https://api.github.com/repos/jenkinsci/ghprb-plugin","forks_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/releases{/id}","created_at":"2012-09-04T13:34:20Z","updated_at":"2015-09-24T18:55:41Z","pushed_at":"2015-09-26T06:28:38Z","git_url":"git://github.com/jenkinsci/ghprb-plugin.git","ssh_url":"git@github.com:jenkinsci/ghprb-plugin.git","clone_url":"https://github.com/jenkinsci/ghprb-plugin.git","svn_url":"https://github.com/jenkinsci/ghprb-plugin","homepage":"https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin","size":2740,"stargazers_count":114,"watchers_count":114,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":32,"forks":163,"open_issues":32,"watchers":114,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"10071d5c76ef5b7236430aa1a1d82a76953d1085","user":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"repo":{"id":5672873,"name":"ghprb-plugin","full_name":"jenkinsci/ghprb-plugin","owner":{"login":"jenkinsci","id":107424,"avatar_url":"https://avatars.githubusercontent.com/u/107424?v=3","gravatar_id":"","url":"https://api.github.com/users/jenkinsci","html_url":"https://github.com/jenkinsci","followers_url":"https://api.github.com/users/jenkinsci/followers","following_url":"https://api.github.com/users/jenkinsci/following{/other_user}","gists_url":"https://api.github.com/users/jenkinsci/gists{/gist_id}","starred_url":"https://api.github.com/users/jenkinsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jenkinsci/subscriptions","organizations_url":"https://api.github.com/users/jenkinsci/orgs","repos_url":"https://api.github.com/users/jenkinsci/repos","events_url":"https://api.github.com/users/jenkinsci/events{/privacy}","received_events_url":"https://api.github.com/users/jenkinsci/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/jenkinsci/ghprb-plugin","description":"github pull requests builder plugin for Jenkins","fork":true,"url":"https://api.github.com/repos/jenkinsci/ghprb-plugin","forks_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/ghprb-plugin/releases{/id}","created_at":"2012-09-04T13:34:20Z","updated_at":"2015-09-24T18:55:41Z","pushed_at":"2015-09-26T06:28:38Z","git_url":"git://github.com/jenkinsci/ghprb-plugin.git","ssh_url":"git@github.com:jenkinsci/ghprb-plugin.git","clone_url":"https://github.com/jenkinsci/ghprb-plugin.git","svn_url":"https://github.com/jenkinsci/ghprb-plugin","homepage":"https://wiki.jenkins-ci.org/display/JENKINS/GitHub+pull+request+builder+plugin","size":2740,"stargazers_count":114,"watchers_count":114,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":163,"mirror_url":null,"open_issues_count":32,"forks":163,"open_issues":32,"watchers":114,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202"},"html":{"href":"https://github.com/jenkinsci/ghprb-plugin/pull/202"},"issue":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/202"},"comments":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/issues/202/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/pulls/202/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/ghprb-plugin/statuses/f34aaa41b2044193f54aff9d434643728f8b0ac1"}}}}