{"action":"created","comment":{"url":"https://api.github.com/repos/codenvy/codenvy/pulls/comments/112386794","pull_request_review_id":33696076,"id":112386794,"diff_hunk":"@@ -99,44 +95,39 @@ public BitbucketServerWebhookService(final AuthConnection authConnection,\n \n     @POST\n     @Consumes(APPLICATION_JSON)\n-    public Response handleWebhookEvent(@Context HttpServletRequest request) throws ServerException {\n+    public Response handleWebhookEvent(PushEvent event) throws ServerException {\n         EnvironmentContext.getCurrent().setSubject(new TokenSubject());\n-        Response response = Response.noContent().build();\n-        try (ServletInputStream inputStream = request.getInputStream()) {\n-            if (inputStream == null) {\n-                return response;\n+        LOG.debug(\"{}\", event);\n+        for (RefChange refChange : event.getRefChanges()) {\n+            Optional<Changeset> changeset = event.getChangesets()\n+                                                 .getValues()\n+                                                 .stream()\n+                                                 .filter(changeSet -> changeSet.getToCommit().getId().equals(refChange.getToHash()))\n+                                                 .findFirst();\n+            if (!changeset.isPresent()) {\n+                continue;\n             }\n-            final PushEvent event = DtoFactory.getInstance().createDtoFromJson(inputStream, PushEvent.class);\n-            LOG.debug(\"{}\", event);\n-            for (RefChange refChange : event.getRefChanges()) {\n-                Optional<Changeset> changeset = event.getChangesets()\n-                                                     .getValues()\n-                                                     .stream()\n-                                                     .filter(changeSet -> changeSet.getToCommit().getId().equals(refChange.getToHash()))\n-                                                     .findFirst();\n-                if (!changeset.isPresent()) {\n-                    continue;\n-                }\n-                String commitMessage = changeset.get().getToCommit().getMessage();\n-                if (commitMessage.startsWith(\"Merge pull request #\")) {\n-                    handleMergeEvent(event, commitMessage);\n-                    continue;\n-                }\n-                String eventType = refChange.getType().toLowerCase();\n-                if (\"update\".equals(eventType) || \"add\".equals(eventType)) {\n+            String commitMessage = changeset.get().getToCommit().getMessage();\n+            if (commitMessage.startsWith(\"Merge pull request #\")) {\n+                handleMergeEvent(event, commitMessage);\n+                continue;\n+            }\n+            String eventType = refChange.getType().toLowerCase();\n+            if (\"update\".equals(eventType) || \"add\".equals(eventType)) {\n+                try {\n                     handlePushEvent(event, refChange.getRefId().substring(11));\n+                } catch (IOException e) {\n+                    LOG.warn(e.getLocalizedMessage());\n+                    throw new ServerException(e.getLocalizedMessage());\n                 }\n             }\n-        } catch (IOException e) {\n-            LOG.error(e.getLocalizedMessage());\n-            throw new ServerException(e.getLocalizedMessage());\n         }\n \n-        return response;\n+        return Response.noContent().build();","path":"plugins/plugin-bitbucket/codenvy-plugin-bitbucketserver-webhooks/src/main/java/com/codenvy/plugin/webhooks/bitbucketserver/BitbucketServerWebhookService.java","position":null,"original_position":79,"commit_id":"5a5fdb7720a3e56bf62c0e87935b201f68d08d18","original_commit_id":"29e15fa04699b2a612c41ef9f9753319a1aefe7a","user":{"login":"vinokurig","id":7668752,"avatar_url":"https://avatars2.githubusercontent.com/u/7668752?v=3","gravatar_id":"","url":"https://api.github.com/users/vinokurig","html_url":"https://github.com/vinokurig","followers_url":"https://api.github.com/users/vinokurig/followers","following_url":"https://api.github.com/users/vinokurig/following{/other_user}","gists_url":"https://api.github.com/users/vinokurig/gists{/gist_id}","starred_url":"https://api.github.com/users/vinokurig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinokurig/subscriptions","organizations_url":"https://api.github.com/users/vinokurig/orgs","repos_url":"https://api.github.com/users/vinokurig/repos","events_url":"https://api.github.com/users/vinokurig/events{/privacy}","received_events_url":"https://api.github.com/users/vinokurig/received_events","type":"User","site_admin":false},"body":"done here and in `JenkinsWebhookService`","created_at":"2017-04-20T07:48:38Z","updated_at":"2017-04-20T07:48:38Z","html_url":"https://github.com/codenvy/codenvy/pull/2097#discussion_r112386794","pull_request_url":"https://api.github.com/repos/codenvy/codenvy/pulls/2097","_links":{"self":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/comments/112386794"},"html":{"href":"https://github.com/codenvy/codenvy/pull/2097#discussion_r112386794"},"pull_request":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/2097"}}},"pull_request":{"url":"https://api.github.com/repos/codenvy/codenvy/pulls/2097","id":116310270,"html_url":"https://github.com/codenvy/codenvy/pull/2097","diff_url":"https://github.com/codenvy/codenvy/pull/2097.diff","patch_url":"https://github.com/codenvy/codenvy/pull/2097.patch","issue_url":"https://api.github.com/repos/codenvy/codenvy/issues/2097","number":2097,"state":"open","locked":false,"title":"ENTERPRISE-61: Add failed build Jenkins integration functionality","user":{"login":"vinokurig","id":7668752,"avatar_url":"https://avatars2.githubusercontent.com/u/7668752?v=3","gravatar_id":"","url":"https://api.github.com/users/vinokurig","html_url":"https://github.com/vinokurig","followers_url":"https://api.github.com/users/vinokurig/followers","following_url":"https://api.github.com/users/vinokurig/following{/other_user}","gists_url":"https://api.github.com/users/vinokurig/gists{/gist_id}","starred_url":"https://api.github.com/users/vinokurig/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinokurig/subscriptions","organizations_url":"https://api.github.com/users/vinokurig/orgs","repos_url":"https://api.github.com/users/vinokurig/repos","events_url":"https://api.github.com/users/vinokurig/events{/privacy}","received_events_url":"https://api.github.com/users/vinokurig/received_events","type":"User","site_admin":false},"body":"<!-- Please review the following before submitting a PR:\r\nPull Request Policy: https://github.com/codenvy/planning/wiki/Development-Workflow#pull-requests\r\n-->\r\n\r\n### What does this PR do?\r\nAdds a service that will receive POST webhooks from Jenkins about a failed build.\r\nGenerates a factory with the commit ID that broke the build as a source of the failed build factory.\r\nAdds the factory link to Jenkins job description.\r\n\r\n### What issues does this PR fix or reference?\r\nhttps://github.com/codenvy/enterprise/issues/61\r\n\r\n#### Changelog\r\nAdded failed build Factory to the Jenkins integration.\r\n\r\n#### Release Notes\r\nWe have improved our Jenkins integration by including links to two factories:\r\n1. A Factory that opens a workspace pre-configured for the project, branch and commit ID that broke the build.\r\n2. A Factory that opens a workspace pre-configured to open the head of the master branch of the project.\r\n\r\nThis makes it easier to diagnose a broken build or quickly review the results of any build. These links will be added to both the Jenkins job description and the email notifications.\r\n\r\nWe have also clarified our configuration docs for the Jenkins integration to make it easier to get started with this capability.\r\n\r\n#### Docs PR\r\nhttps://github.com/codenvy/docs/pull/113\r\n","created_at":"2017-04-18T11:53:43Z","updated_at":"2017-04-20T07:48:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"0bb91e974c25b45114c2e25be0f4ae549c8b77d2","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/codenvy/codenvy/pulls/2097/commits","review_comments_url":"https://api.github.com/repos/codenvy/codenvy/pulls/2097/comments","review_comment_url":"https://api.github.com/repos/codenvy/codenvy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/codenvy/codenvy/issues/2097/comments","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/5a5fdb7720a3e56bf62c0e87935b201f68d08d18","head":{"label":"codenvy:ENTERPRISE-61","ref":"ENTERPRISE-61","sha":"5a5fdb7720a3e56bf62c0e87935b201f68d08d18","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars1.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":54102761,"name":"codenvy","full_name":"codenvy/codenvy","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars1.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/codenvy","description":"Codenvy","fork":false,"url":"https://api.github.com/repos/codenvy/codenvy","forks_url":"https://api.github.com/repos/codenvy/codenvy/forks","keys_url":"https://api.github.com/repos/codenvy/codenvy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/codenvy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/codenvy/teams","hooks_url":"https://api.github.com/repos/codenvy/codenvy/hooks","issue_events_url":"https://api.github.com/repos/codenvy/codenvy/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/codenvy/events","assignees_url":"https://api.github.com/repos/codenvy/codenvy/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/codenvy/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/codenvy/tags","blobs_url":"https://api.github.com/repos/codenvy/codenvy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/codenvy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/codenvy/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/codenvy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/codenvy/languages","stargazers_url":"https://api.github.com/repos/codenvy/codenvy/stargazers","contributors_url":"https://api.github.com/repos/codenvy/codenvy/contributors","subscribers_url":"https://api.github.com/repos/codenvy/codenvy/subscribers","subscription_url":"https://api.github.com/repos/codenvy/codenvy/subscription","commits_url":"https://api.github.com/repos/codenvy/codenvy/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/codenvy/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/codenvy/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/codenvy/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/codenvy/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/codenvy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/codenvy/merges","archive_url":"https://api.github.com/repos/codenvy/codenvy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/codenvy/downloads","issues_url":"https://api.github.com/repos/codenvy/codenvy/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/codenvy/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/codenvy/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/codenvy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/codenvy/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/codenvy/releases{/id}","deployments_url":"https://api.github.com/repos/codenvy/codenvy/deployments","created_at":"2016-03-17T08:51:27Z","updated_at":"2017-04-19T07:13:29Z","pushed_at":"2017-04-20T07:44:56Z","git_url":"git://github.com/codenvy/codenvy.git","ssh_url":"git@github.com:codenvy/codenvy.git","clone_url":"https://github.com/codenvy/codenvy.git","svn_url":"https://github.com/codenvy/codenvy","homepage":null,"size":144968,"stargazers_count":77,"watchers_count":77,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":216,"forks":55,"open_issues":216,"watchers":77,"default_branch":"master"}},"base":{"label":"codenvy:master","ref":"master","sha":"ea243a42583ed1dc0b72479fb57b51e6b0c0b887","user":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars1.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"repo":{"id":54102761,"name":"codenvy","full_name":"codenvy/codenvy","owner":{"login":"codenvy","id":2736247,"avatar_url":"https://avatars1.githubusercontent.com/u/2736247?v=3","gravatar_id":"","url":"https://api.github.com/users/codenvy","html_url":"https://github.com/codenvy","followers_url":"https://api.github.com/users/codenvy/followers","following_url":"https://api.github.com/users/codenvy/following{/other_user}","gists_url":"https://api.github.com/users/codenvy/gists{/gist_id}","starred_url":"https://api.github.com/users/codenvy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codenvy/subscriptions","organizations_url":"https://api.github.com/users/codenvy/orgs","repos_url":"https://api.github.com/users/codenvy/repos","events_url":"https://api.github.com/users/codenvy/events{/privacy}","received_events_url":"https://api.github.com/users/codenvy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/codenvy/codenvy","description":"Codenvy","fork":false,"url":"https://api.github.com/repos/codenvy/codenvy","forks_url":"https://api.github.com/repos/codenvy/codenvy/forks","keys_url":"https://api.github.com/repos/codenvy/codenvy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codenvy/codenvy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codenvy/codenvy/teams","hooks_url":"https://api.github.com/repos/codenvy/codenvy/hooks","issue_events_url":"https://api.github.com/repos/codenvy/codenvy/issues/events{/number}","events_url":"https://api.github.com/repos/codenvy/codenvy/events","assignees_url":"https://api.github.com/repos/codenvy/codenvy/assignees{/user}","branches_url":"https://api.github.com/repos/codenvy/codenvy/branches{/branch}","tags_url":"https://api.github.com/repos/codenvy/codenvy/tags","blobs_url":"https://api.github.com/repos/codenvy/codenvy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codenvy/codenvy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codenvy/codenvy/git/refs{/sha}","trees_url":"https://api.github.com/repos/codenvy/codenvy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codenvy/codenvy/statuses/{sha}","languages_url":"https://api.github.com/repos/codenvy/codenvy/languages","stargazers_url":"https://api.github.com/repos/codenvy/codenvy/stargazers","contributors_url":"https://api.github.com/repos/codenvy/codenvy/contributors","subscribers_url":"https://api.github.com/repos/codenvy/codenvy/subscribers","subscription_url":"https://api.github.com/repos/codenvy/codenvy/subscription","commits_url":"https://api.github.com/repos/codenvy/codenvy/commits{/sha}","git_commits_url":"https://api.github.com/repos/codenvy/codenvy/git/commits{/sha}","comments_url":"https://api.github.com/repos/codenvy/codenvy/comments{/number}","issue_comment_url":"https://api.github.com/repos/codenvy/codenvy/issues/comments{/number}","contents_url":"https://api.github.com/repos/codenvy/codenvy/contents/{+path}","compare_url":"https://api.github.com/repos/codenvy/codenvy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codenvy/codenvy/merges","archive_url":"https://api.github.com/repos/codenvy/codenvy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codenvy/codenvy/downloads","issues_url":"https://api.github.com/repos/codenvy/codenvy/issues{/number}","pulls_url":"https://api.github.com/repos/codenvy/codenvy/pulls{/number}","milestones_url":"https://api.github.com/repos/codenvy/codenvy/milestones{/number}","notifications_url":"https://api.github.com/repos/codenvy/codenvy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codenvy/codenvy/labels{/name}","releases_url":"https://api.github.com/repos/codenvy/codenvy/releases{/id}","deployments_url":"https://api.github.com/repos/codenvy/codenvy/deployments","created_at":"2016-03-17T08:51:27Z","updated_at":"2017-04-19T07:13:29Z","pushed_at":"2017-04-20T07:44:56Z","git_url":"git://github.com/codenvy/codenvy.git","ssh_url":"git@github.com:codenvy/codenvy.git","clone_url":"https://github.com/codenvy/codenvy.git","svn_url":"https://github.com/codenvy/codenvy","homepage":null,"size":144968,"stargazers_count":77,"watchers_count":77,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":216,"forks":55,"open_issues":216,"watchers":77,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/2097"},"html":{"href":"https://github.com/codenvy/codenvy/pull/2097"},"issue":{"href":"https://api.github.com/repos/codenvy/codenvy/issues/2097"},"comments":{"href":"https://api.github.com/repos/codenvy/codenvy/issues/2097/comments"},"review_comments":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/2097/comments"},"review_comment":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/codenvy/codenvy/pulls/2097/commits"},"statuses":{"href":"https://api.github.com/repos/codenvy/codenvy/statuses/5a5fdb7720a3e56bf62c0e87935b201f68d08d18"}}}}
{"actor":{"display_login":"vinokurig"}}