{"action":"created","comment":{"url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/comments/72076955","id":72076955,"diff_hunk":"@@ -0,0 +1,64 @@\n+package hudson.plugins.tfs;\r\n+\r\n+import hudson.Extension;\r\n+import hudson.FilePath;\r\n+import hudson.Launcher;\r\n+import hudson.model.AbstractProject;\r\n+import hudson.model.Run;\r\n+import hudson.model.TaskListener;\r\n+import hudson.plugins.tfs.util.VstsStatus;\r\n+import hudson.tasks.BuildStepDescriptor;\r\n+import hudson.tasks.BuildStepMonitor;\r\n+import hudson.tasks.Notifier;\r\n+import hudson.tasks.Publisher;\r\n+import jenkins.tasks.SimpleBuildStep;\r\n+import org.kohsuke.stapler.DataBoundConstructor;\r\n+\r\n+import javax.annotation.Nonnull;\r\n+import java.io.IOException;\r\n+\r\n+/**\r\n+ * A _Post-Build Action_ that reports the completion status of an associated build to VSTS.\r\n+ */\r\n+public class VstsCompletedStatusPostBuildAction extends Notifier implements SimpleBuildStep {\r\n+\r\n+    @DataBoundConstructor\r\n+    public VstsCompletedStatusPostBuildAction() {\r\n+\r\n+    }\r\n+\r\n+    @Override\r\n+    public void perform(\r\n+            @Nonnull final Run<?, ?> run,\r\n+            @Nonnull final FilePath workspace,\r\n+            @Nonnull final Launcher launcher,\r\n+            @Nonnull final TaskListener listener\r\n+    ) throws InterruptedException, IOException {\r\n+        try {\r\n+            VstsStatus.createFromRun(run);\r\n+        }\r\n+        catch (final Exception e) {\r\n+            e.printStackTrace(listener.error(\"Error while trying to update completion status in VSTS\"));\r\n+        }\r\n+    }\r\n+\r\n+    @Override\r\n+    public BuildStepMonitor getRequiredMonitorService() {\r\n+        // we don't need the outcome of any previous builds for this step\r\n+        return BuildStepMonitor.NONE;\r\n+    }\r\n+\r\n+    @Extension\r\n+    public static class DescriptorImpl extends BuildStepDescriptor<Publisher> {\r\n+\r\n+        @Override\r\n+        public boolean isApplicable(final Class<? extends AbstractProject> jobType) {\r\n+            return true;\r\n+        }\r\n+\r\n+        @Override\r\n+        public String getDisplayName() {\r\n+            return \"Set completion status for VSTS commit or pull request\";\r","path":"src/main/java/hudson/plugins/tfs/VstsCompletedStatusPostBuildAction.java","position":61,"original_position":61,"commit_id":"b3c7fdfec28163d82fe986a9ed94d5361e3554b7","original_commit_id":"b3c7fdfec28163d82fe986a9ed94d5361e3554b7","user":{"login":"DavidStaheli","id":1767415,"avatar_url":"https://avatars.githubusercontent.com/u/1767415?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidStaheli","html_url":"https://github.com/DavidStaheli","followers_url":"https://api.github.com/users/DavidStaheli/followers","following_url":"https://api.github.com/users/DavidStaheli/following{/other_user}","gists_url":"https://api.github.com/users/DavidStaheli/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidStaheli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidStaheli/subscriptions","organizations_url":"https://api.github.com/users/DavidStaheli/orgs","repos_url":"https://api.github.com/users/DavidStaheli/repos","events_url":"https://api.github.com/users/DavidStaheli/events{/privacy}","received_events_url":"https://api.github.com/users/DavidStaheli/received_events","type":"User","site_admin":false},"body":"Can we change \"VSTS\" to \"Team Services\" here?","created_at":"2016-07-25T14:47:03Z","updated_at":"2016-07-25T14:47:03Z","html_url":"https://github.com/jenkinsci/tfs-plugin/pull/91#discussion_r72076955","pull_request_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91","_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/comments/72076955"},"html":{"href":"https://github.com/jenkinsci/tfs-plugin/pull/91#discussion_r72076955"},"pull_request":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91","id":78560364,"html_url":"https://github.com/jenkinsci/tfs-plugin/pull/91","diff_url":"https://github.com/jenkinsci/tfs-plugin/pull/91.diff","patch_url":"https://github.com/jenkinsci/tfs-plugin/pull/91.patch","issue_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/91","number":91,"state":"open","locked":false,"title":"Report pending and completion status to the associated VSTS commit","user":{"login":"olivierdagenais","id":297515,"avatar_url":"https://avatars.githubusercontent.com/u/297515?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierdagenais","html_url":"https://github.com/olivierdagenais","followers_url":"https://api.github.com/users/olivierdagenais/followers","following_url":"https://api.github.com/users/olivierdagenais/following{/other_user}","gists_url":"https://api.github.com/users/olivierdagenais/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierdagenais/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierdagenais/subscriptions","organizations_url":"https://api.github.com/users/olivierdagenais/orgs","repos_url":"https://api.github.com/users/olivierdagenais/repos","events_url":"https://api.github.com/users/olivierdagenais/events{/privacy}","received_events_url":"https://api.github.com/users/olivierdagenais/received_events","type":"User","site_admin":false},"body":"This pull request adds a **Set pending status for VSTS commit or pull request** _build step_ as well as a **Set completion status for VSTS commit or pull request** _post-build action_, as shown below in my test job:\r\n\r\n![image](https://cloud.githubusercontent.com/assets/297515/17075149/c169d12c-5058-11e6-88dd-094f50fa6b65.png)\r\n\r\nManual testing\r\n--------------\r\n\r\n1. Triggered the `/vsts-hook/` with a specific commit, which queued my test job.\r\n2. As soon as the Maven build started, I went to check on the commit in VSTS.  It had indeed received the \"Pending\" status.\r\n3. As soon as the build completed successfully, I went to check on the commit in VSTS.  It had indeed received a \"Success\" status and was linking back to the Jenkins job.\r\n4. I repeated the test, this time arranging for the build to fail.  VSTS indeed reported a \"Failure\" status, also linking back to the Jenkins job.\r\n\r\nMission accomplished!","created_at":"2016-07-23T02:12:16Z","updated_at":"2016-07-25T14:47:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b94237b97c3cb10d651fe7e7e678ea4c803cb89b","assignee":{"login":"DavidStaheli","id":1767415,"avatar_url":"https://avatars.githubusercontent.com/u/1767415?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidStaheli","html_url":"https://github.com/DavidStaheli","followers_url":"https://api.github.com/users/DavidStaheli/followers","following_url":"https://api.github.com/users/DavidStaheli/following{/other_user}","gists_url":"https://api.github.com/users/DavidStaheli/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidStaheli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidStaheli/subscriptions","organizations_url":"https://api.github.com/users/DavidStaheli/orgs","repos_url":"https://api.github.com/users/DavidStaheli/repos","events_url":"https://api.github.com/users/DavidStaheli/events{/privacy}","received_events_url":"https://api.github.com/users/DavidStaheli/received_events","type":"User","site_admin":false},"assignees":[{"login":"DavidStaheli","id":1767415,"avatar_url":"https://avatars.githubusercontent.com/u/1767415?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidStaheli","html_url":"https://github.com/DavidStaheli","followers_url":"https://api.github.com/users/DavidStaheli/followers","following_url":"https://api.github.com/users/DavidStaheli/following{/other_user}","gists_url":"https://api.github.com/users/DavidStaheli/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidStaheli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidStaheli/subscriptions","organizations_url":"https://api.github.com/users/DavidStaheli/orgs","repos_url":"https://api.github.com/users/DavidStaheli/repos","events_url":"https://api.github.com/users/DavidStaheli/events{/privacy}","received_events_url":"https://api.github.com/users/DavidStaheli/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91/commits","review_comments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91/comments","review_comment_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/91/comments","statuses_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/statuses/b3c7fdfec28163d82fe986a9ed94d5361e3554b7","head":{"label":"jenkinsci:report_status_to_vsts_steps","ref":"report_status_to_vsts_steps","sha":"b3c7fdfec28163d82fe986a9ed94d5361e3554b7","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":1163806,"name":"tfs-plugin","full_name":"jenkinsci/tfs-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/tfs-plugin","description":"Jenkins tfs plugin","fork":false,"url":"https://api.github.com/repos/jenkinsci/tfs-plugin","forks_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/deployments","created_at":"2010-12-13T05:58:27Z","updated_at":"2016-07-17T19:24:14Z","pushed_at":"2016-07-25T01:31:28Z","git_url":"git://github.com/jenkinsci/tfs-plugin.git","ssh_url":"git@github.com:jenkinsci/tfs-plugin.git","clone_url":"https://github.com/jenkinsci/tfs-plugin.git","svn_url":"https://github.com/jenkinsci/tfs-plugin","homepage":"http://jenkins-ci.org/","size":54652,"stargazers_count":63,"watchers_count":63,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":15,"forks":83,"open_issues":15,"watchers":63,"default_branch":"master"}},"base":{"label":"jenkinsci:master","ref":"master","sha":"bf1865522d18777d3cfc57f3ac4dc85fb51969f1","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":1163806,"name":"tfs-plugin","full_name":"jenkinsci/tfs-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/tfs-plugin","description":"Jenkins tfs plugin","fork":false,"url":"https://api.github.com/repos/jenkinsci/tfs-plugin","forks_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/forks","keys_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/teams","hooks_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/hooks","issue_events_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/events{/number}","events_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/events","assignees_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/assignees{/user}","branches_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/branches{/branch}","tags_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/tags","blobs_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/refs{/sha}","trees_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/statuses/{sha}","languages_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/languages","stargazers_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/stargazers","contributors_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/contributors","subscribers_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/subscribers","subscription_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/subscription","commits_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/commits{/sha}","git_commits_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/git/commits{/sha}","comments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/comments{/number}","issue_comment_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/comments{/number}","contents_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/contents/{+path}","compare_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/merges","archive_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/downloads","issues_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues{/number}","pulls_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls{/number}","milestones_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/milestones{/number}","notifications_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/labels{/name}","releases_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/releases{/id}","deployments_url":"https://api.github.com/repos/jenkinsci/tfs-plugin/deployments","created_at":"2010-12-13T05:58:27Z","updated_at":"2016-07-17T19:24:14Z","pushed_at":"2016-07-25T01:31:28Z","git_url":"git://github.com/jenkinsci/tfs-plugin.git","ssh_url":"git@github.com:jenkinsci/tfs-plugin.git","clone_url":"https://github.com/jenkinsci/tfs-plugin.git","svn_url":"https://github.com/jenkinsci/tfs-plugin","homepage":"http://jenkins-ci.org/","size":54652,"stargazers_count":63,"watchers_count":63,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":83,"mirror_url":null,"open_issues_count":15,"forks":83,"open_issues":15,"watchers":63,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91"},"html":{"href":"https://github.com/jenkinsci/tfs-plugin/pull/91"},"issue":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/91"},"comments":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91/comments"},"review_comment":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/pulls/91/commits"},"statuses":{"href":"https://api.github.com/repos/jenkinsci/tfs-plugin/statuses/b3c7fdfec28163d82fe986a9ed94d5361e3554b7"}}}}
{"actor":{"display_login":"DavidStaheli"}}