{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments/74415233","id":74415233,"diff_hunk":"@@ -172,52 +71,108 @@ function isPrBuild(): boolean {\n         sourceBranch.toLowerCase().startsWith(\"refs/pull/\");\n }\n \n+/**\n+ * Returns, as an object, the contents of the report-task.txt file created by SonarQube plugins\n+ * The returned object contains the following properties:\n+ *     projectKey, serverUrl, dashboardUrl, ceTaskId, ceTaskUrl\n+ * @param sonarPluginFolder The folder created by SonarQube integration during build\n+ * @returns {SonarQubeRunSettings} An object with fields corresponding to the properties exposed in report-task.txt, or null if PR build\n+ */\n+function getSonarQubeRunSettings(sonarPluginFolder: string): SonarQubeRunSettings {\n+    if (isPrBuild()) {\n+        return null;\n+    }\n+\n+    var reportFilePath:string = path.join(sonarPluginFolder, 'report-task.txt');\n+    return SonarQubeRunSettings.createRunSettingsFromFile(reportFilePath);\n+}\n+\n+/**\n+ * Returns the appropriate SQMetrics object for this build.\n+ * @param sqRunSettings An object with fields corresponding to the properties exposed in report-task.txt\n+ * @returns {SonarQubeMetrics} An SQMetrics instance for this build on the SQ server, or null if PR build\n+ */\n+function getSonarQubeMetrics(sqRunSettings:SonarQubeRunSettings): SonarQubeMetrics {\n+    if (isPrBuild()) {\n+        return null;\n+    }\n+\n+    var sqServer:ISonarQubeServer = new SonarQubeServer(SonarQubeEndpoint.createSonarQubeEndpoint());\n+    return new SonarQubeMetrics(sqServer, sqRunSettings.ceTaskId);\n+}\n+\n function isNullOrEmpty(str) {\n     return str === undefined || str === null || str.length === 0;\n }\n \n /**\n- * Creates the string that comprises the build summary text, given the location of the /sonar build folder.\n- * @param sqBuildFolder\n- * @returns {any}\n+ * Handle checking the status of the quality gate and failing the build if the quality gate has failed.\n+ * No action is taken if the feature is not enabled, or sqRunSettings argument is null.\n+ * @param sqRunSettings SonarQubeRunSettings object for this build or null if this is a PR build and the object could not be created\n+ * @param sqMetrics     SonarQube metrics for the applicable run\n+ * @returns {Q.Promise<void>} Promise resolved when action completes.\n  */\n-function createSonarQubeBuildSummary(sqBuildFolder:string):Q.Promise<string> {\n-    // Task report is not created for PR builds - inform the user in the build summary\n-    if (isPrBuild()) {\n-        tl.debug('Pull request build, will not attempt to fetch detailed SonarQube report');\n-        // Looks like: Detailed SonarQube reports are not available for pull request builds.\n-        return Q.when(tl.loc('sqAnalysis_BuildSummaryNotAvailableInPrBuild'));\n+function processSonarQubeBuildBreaker(sqRunSettings:SonarQubeRunSettings, sqMetrics:SonarQubeMetrics):Q.Promise<void> {","path":"Tasks/Gradle/CodeAnalysis/SonarQube/common.ts","position":249,"original_position":249,"commit_id":"830af642f7d51b9d7e282cc4f371d20c1d24cd6d","original_commit_id":"830af642f7d51b9d7e282cc4f371d20c1d24cd6d","user":{"login":"HSAR","id":985911,"avatar_url":"https://avatars.githubusercontent.com/u/985911?v=3","gravatar_id":"","url":"https://api.github.com/users/HSAR","html_url":"https://github.com/HSAR","followers_url":"https://api.github.com/users/HSAR/followers","following_url":"https://api.github.com/users/HSAR/following{/other_user}","gists_url":"https://api.github.com/users/HSAR/gists{/gist_id}","starred_url":"https://api.github.com/users/HSAR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSAR/subscriptions","organizations_url":"https://api.github.com/users/HSAR/orgs","repos_url":"https://api.github.com/users/HSAR/repos","events_url":"https://api.github.com/users/HSAR/events{/privacy}","received_events_url":"https://api.github.com/users/HSAR/received_events","type":"User","site_admin":false},"body":"Accepted, in progress. Will move all of the build breaker, build summary and isPR stuff into a class related to the VSTS server side.","created_at":"2016-08-11T12:48:24Z","updated_at":"2016-08-11T12:48:24Z","html_url":"https://github.com/Microsoft/vsts-tasks/pull/2246#discussion_r74415233","pull_request_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments/74415233"},"html":{"href":"https://github.com/Microsoft/vsts-tasks/pull/2246#discussion_r74415233"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246","id":80655447,"html_url":"https://github.com/Microsoft/vsts-tasks/pull/2246","diff_url":"https://github.com/Microsoft/vsts-tasks/pull/2246.diff","patch_url":"https://github.com/Microsoft/vsts-tasks/pull/2246.patch","issue_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/2246","number":2246,"state":"open","locked":false,"title":"SonarQube on Maven and Gradle can fail the build on quality gate fail…","user":{"login":"HSAR","id":985911,"avatar_url":"https://avatars.githubusercontent.com/u/985911?v=3","gravatar_id":"","url":"https://api.github.com/users/HSAR","html_url":"https://github.com/HSAR","followers_url":"https://api.github.com/users/HSAR/followers","following_url":"https://api.github.com/users/HSAR/following{/other_user}","gists_url":"https://api.github.com/users/HSAR/gists{/gist_id}","starred_url":"https://api.github.com/users/HSAR/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HSAR/subscriptions","organizations_url":"https://api.github.com/users/HSAR/orgs","repos_url":"https://api.github.com/users/HSAR/repos","events_url":"https://api.github.com/users/HSAR/events{/privacy}","received_events_url":"https://api.github.com/users/HSAR/received_events","type":"User","site_admin":false},"body":"…ure.","created_at":"2016-08-09T16:50:22Z","updated_at":"2016-08-11T12:48:24Z","closed_at":null,"merged_at":null,"merge_commit_sha":"33e309744b7ff21fc14ecf0ccc147dbdc4a940e9","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246/commits","review_comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246/comments","review_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/2246/comments","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/830af642f7d51b9d7e282cc4f371d20c1d24cd6d","head":{"label":"Microsoft:users/sschen/javatools","ref":"users/sschen/javatools","sha":"830af642f7d51b9d7e282cc4f371d20c1d24cd6d","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27631673,"name":"vsts-tasks","full_name":"Microsoft/vsts-tasks","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-tasks","description":"Build and Release Tasks for Visual Studio Team Services and Team Foundation Server","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-tasks","forks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-tasks/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-tasks/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-tasks/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-tasks/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-tasks/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/deployments","created_at":"2014-12-06T11:11:46Z","updated_at":"2016-08-11T05:48:18Z","pushed_at":"2016-08-11T10:04:23Z","git_url":"git://github.com/Microsoft/vsts-tasks.git","ssh_url":"git@github.com:Microsoft/vsts-tasks.git","clone_url":"https://github.com/Microsoft/vsts-tasks.git","svn_url":"https://github.com/Microsoft/vsts-tasks","homepage":"https://www.visualstudio.com/features/devops-vs","size":17912,"stargazers_count":372,"watchers_count":372,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":328,"mirror_url":null,"open_issues_count":118,"forks":328,"open_issues":118,"watchers":372,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"d8ec0818b0b4c5a492ebe4f59daef38bdd1d7626","user":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"repo":{"id":27631673,"name":"vsts-tasks","full_name":"Microsoft/vsts-tasks","owner":{"login":"Microsoft","id":6154722,"avatar_url":"https://avatars.githubusercontent.com/u/6154722?v=3","gravatar_id":"","url":"https://api.github.com/users/Microsoft","html_url":"https://github.com/Microsoft","followers_url":"https://api.github.com/users/Microsoft/followers","following_url":"https://api.github.com/users/Microsoft/following{/other_user}","gists_url":"https://api.github.com/users/Microsoft/gists{/gist_id}","starred_url":"https://api.github.com/users/Microsoft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Microsoft/subscriptions","organizations_url":"https://api.github.com/users/Microsoft/orgs","repos_url":"https://api.github.com/users/Microsoft/repos","events_url":"https://api.github.com/users/Microsoft/events{/privacy}","received_events_url":"https://api.github.com/users/Microsoft/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Microsoft/vsts-tasks","description":"Build and Release Tasks for Visual Studio Team Services and Team Foundation Server","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-tasks","forks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-tasks/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-tasks/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-tasks/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-tasks/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-tasks/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-tasks/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-tasks/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-tasks/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-tasks/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-tasks/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-tasks/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-tasks/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-tasks/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-tasks/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-tasks/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-tasks/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-tasks/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-tasks/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-tasks/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-tasks/deployments","created_at":"2014-12-06T11:11:46Z","updated_at":"2016-08-11T05:48:18Z","pushed_at":"2016-08-11T10:04:23Z","git_url":"git://github.com/Microsoft/vsts-tasks.git","ssh_url":"git@github.com:Microsoft/vsts-tasks.git","clone_url":"https://github.com/Microsoft/vsts-tasks.git","svn_url":"https://github.com/Microsoft/vsts-tasks","homepage":"https://www.visualstudio.com/features/devops-vs","size":17912,"stargazers_count":372,"watchers_count":372,"language":"PowerShell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":328,"mirror_url":null,"open_issues_count":118,"forks":328,"open_issues":118,"watchers":372,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246"},"html":{"href":"https://github.com/Microsoft/vsts-tasks/pull/2246"},"issue":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/2246"},"comments":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/issues/2246/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/pulls/2246/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/vsts-tasks/statuses/830af642f7d51b9d7e282cc4f371d20c1d24cd6d"}}}}
{"actor":{"display_login":"HSAR"}}