{"action":"created","comment":{"url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments/58860262","id":58860262,"diff_hunk":"@@ -0,0 +1,261 @@\n+using System;\n+using System.Collections.Generic;\n+using System.IO;\n+using System.Linq;\n+using System.Threading.Tasks;\n+\n+using Agent.Worker.Release.Artifacts.Definition;\n+\n+using Microsoft.VisualStudio.Services.Agent.Util;\n+using Microsoft.VisualStudio.Services.ReleaseManagement.WebApi.Contracts;\n+\n+namespace Microsoft.VisualStudio.Services.Agent.Worker.Release\n+{\n+    public sealed class ReleaseJobExtension : AgentService, IJobExtension\n+    {\n+        public Type ExtensionType => typeof(IJobExtension);\n+\n+        public string HostType => \"release\";\n+\n+        public IStep PrepareStep { get; private set; }\n+\n+        public IStep FinallyStep { get; private set; }\n+\n+        // TODO: These methods seems not relevant to Release Extension, refactor it\n+        public void GetRootedPath(IExecutionContext context, string path, out string rootedPath)\n+        {\n+            throw new NotImplementedException();\n+        }\n+\n+        public void ConvertLocalPath(IExecutionContext context, string localPath, out string repoName, out string sourcePath)\n+        {\n+            throw new NotImplementedException();\n+        }\n+\n+        public ReleaseJobExtension()\n+        {\n+            PrepareStep = new JobExtensionRunner(\n+                runAsync: PrepareAsync,\n+                alwaysRun: false,\n+                continueOnError: false,\n+                critical: true,\n+                displayName: StringUtil.Loc(\"DownloadArtifacts\"),\n+                enabled: true,\n+                @finally: false);\n+        }\n+\n+        public async Task PrepareAsync()\n+        {\n+            Trace.Entering();\n+\n+            ArgUtil.NotNull(PrepareStep, nameof(PrepareStep));\n+            ArgUtil.NotNull(PrepareStep.ExecutionContext, nameof(PrepareStep.ExecutionContext));\n+\n+            int releaseId;\n+            Guid teamProjectId;\n+            string artifactsWorkingFolder;\n+            bool skipArtifactsDownload;\n+\n+            IExecutionContext executionContext = PrepareStep.ExecutionContext;\n+            InitializeAgent(executionContext, out skipArtifactsDownload, out teamProjectId, out artifactsWorkingFolder, out releaseId);\n+\n+            if (!skipArtifactsDownload)\n+            {\n+                // TODO: Create this as new task. Old windows agent does this. First is initialize which does the above and download task will be added based on skipDownloadArtifact option\n+                executionContext.Output(\"Downloading artifact\");\n+\n+                await DownloadArtifacts(executionContext, teamProjectId, artifactsWorkingFolder, releaseId);\n+            }\n+        }\n+\n+        private async Task DownloadArtifacts(IExecutionContext executionContext, Guid teamProjectId, string artifactsWorkingFolder, int releaseId)\n+        {\n+            Trace.Entering();\n+            try\n+            {\n+                var agentServer = HostContext.GetService<IAgentServer>();\n+                // TODO: send correct cancellation token\n+                List<AgentArtifactDefinition> releaseArtifacts =\n+                    agentServer.GetReleaseArtifactsFromService(teamProjectId, releaseId).ToList();\n+\n+                releaseArtifacts.ForEach(x => Trace.Info($\"Found Artifact = {x.Alias}\"));\n+\n+                CleanUpArtifactsFolder(executionContext, artifactsWorkingFolder);\n+                await DownloadArtifacts(executionContext, releaseArtifacts, artifactsWorkingFolder);\n+            }\n+            catch (Exception ex)\n+            {\n+                executionContext.Error(ex);\n+                throw;\n+            }","path":"src/Agent.Worker/Release/ReleaseJobExtension.cs","position":90,"original_position":90,"commit_id":"632ebf0a20d0f2cdc415149150e390284a92b916","original_commit_id":"632ebf0a20d0f2cdc415149150e390284a92b916","user":{"login":"kasubram","id":17177298,"avatar_url":"https://avatars.githubusercontent.com/u/17177298?v=3","gravatar_id":"","url":"https://api.github.com/users/kasubram","html_url":"https://github.com/kasubram","followers_url":"https://api.github.com/users/kasubram/followers","following_url":"https://api.github.com/users/kasubram/following{/other_user}","gists_url":"https://api.github.com/users/kasubram/gists{/gist_id}","starred_url":"https://api.github.com/users/kasubram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasubram/subscriptions","organizations_url":"https://api.github.com/users/kasubram/orgs","repos_url":"https://api.github.com/users/kasubram/repos","events_url":"https://api.github.com/users/kasubram/events{/privacy}","received_events_url":"https://api.github.com/users/kasubram/received_events","type":"User","site_admin":false},"body":"Fixed it","created_at":"2016-04-07T12:11:10Z","updated_at":"2016-04-07T12:11:10Z","html_url":"https://github.com/Microsoft/vsts-agent/pull/48#discussion_r58860262","pull_request_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48","_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments/58860262"},"html":{"href":"https://github.com/Microsoft/vsts-agent/pull/48#discussion_r58860262"},"pull_request":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48"}}},"pull_request":{"url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48","id":65473324,"html_url":"https://github.com/Microsoft/vsts-agent/pull/48","diff_url":"https://github.com/Microsoft/vsts-agent/pull/48.diff","patch_url":"https://github.com/Microsoft/vsts-agent/pull/48.patch","issue_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/48","number":48,"state":"open","locked":false,"title":"Early draft of RM extension","user":{"login":"kasubram","id":17177298,"avatar_url":"https://avatars.githubusercontent.com/u/17177298?v=3","gravatar_id":"","url":"https://api.github.com/users/kasubram","html_url":"https://github.com/kasubram","followers_url":"https://api.github.com/users/kasubram/followers","following_url":"https://api.github.com/users/kasubram/following{/other_user}","gists_url":"https://api.github.com/users/kasubram/gists{/gist_id}","starred_url":"https://api.github.com/users/kasubram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kasubram/subscriptions","organizations_url":"https://api.github.com/users/kasubram/orgs","repos_url":"https://api.github.com/users/kasubram/repos","events_url":"https://api.github.com/users/kasubram/events{/privacy}","received_events_url":"https://api.github.com/users/kasubram/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-06T14:14:21Z","updated_at":"2016-04-07T12:11:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"789f1f5ccdf8b67c37d31798b56492230c128a16","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48/commits","review_comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48/comments","review_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/48/comments","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/632ebf0a20d0f2cdc415149150e390284a92b916","head":{"label":"Microsoft:users/kasubram/rmextension","ref":"users/kasubram/rmextension","sha":"632ebf0a20d0f2cdc415149150e390284a92b916","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":53052789,"name":"vsts-agent","full_name":"Microsoft/vsts-agent","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-agent","description":"Visual Studio Team Services Build and Release Agent","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-agent","forks_url":"https://api.github.com/repos/Microsoft/vsts-agent/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-agent/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-agent/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-agent/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-agent/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-agent/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-agent/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-agent/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-agent/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-agent/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-agent/deployments","created_at":"2016-03-03T13:36:48Z","updated_at":"2016-04-05T00:56:49Z","pushed_at":"2016-04-07T06:43:13Z","git_url":"git://github.com/Microsoft/vsts-agent.git","ssh_url":"git@github.com:Microsoft/vsts-agent.git","clone_url":"https://github.com/Microsoft/vsts-agent.git","svn_url":"https://github.com/Microsoft/vsts-agent","homepage":null,"size":656,"stargazers_count":20,"watchers_count":20,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":20,"default_branch":"master"}},"base":{"label":"Microsoft:master","ref":"master","sha":"4d727ccbca164b22f59d456ea52ad4ce3c548efe","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":53052789,"name":"vsts-agent","full_name":"Microsoft/vsts-agent","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-agent","description":"Visual Studio Team Services Build and Release Agent","fork":false,"url":"https://api.github.com/repos/Microsoft/vsts-agent","forks_url":"https://api.github.com/repos/Microsoft/vsts-agent/forks","keys_url":"https://api.github.com/repos/Microsoft/vsts-agent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Microsoft/vsts-agent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Microsoft/vsts-agent/teams","hooks_url":"https://api.github.com/repos/Microsoft/vsts-agent/hooks","issue_events_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/events{/number}","events_url":"https://api.github.com/repos/Microsoft/vsts-agent/events","assignees_url":"https://api.github.com/repos/Microsoft/vsts-agent/assignees{/user}","branches_url":"https://api.github.com/repos/Microsoft/vsts-agent/branches{/branch}","tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/tags","blobs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/refs{/sha}","trees_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/{sha}","languages_url":"https://api.github.com/repos/Microsoft/vsts-agent/languages","stargazers_url":"https://api.github.com/repos/Microsoft/vsts-agent/stargazers","contributors_url":"https://api.github.com/repos/Microsoft/vsts-agent/contributors","subscribers_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscribers","subscription_url":"https://api.github.com/repos/Microsoft/vsts-agent/subscription","commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/commits{/sha}","git_commits_url":"https://api.github.com/repos/Microsoft/vsts-agent/git/commits{/sha}","comments_url":"https://api.github.com/repos/Microsoft/vsts-agent/comments{/number}","issue_comment_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues/comments{/number}","contents_url":"https://api.github.com/repos/Microsoft/vsts-agent/contents/{+path}","compare_url":"https://api.github.com/repos/Microsoft/vsts-agent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Microsoft/vsts-agent/merges","archive_url":"https://api.github.com/repos/Microsoft/vsts-agent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Microsoft/vsts-agent/downloads","issues_url":"https://api.github.com/repos/Microsoft/vsts-agent/issues{/number}","pulls_url":"https://api.github.com/repos/Microsoft/vsts-agent/pulls{/number}","milestones_url":"https://api.github.com/repos/Microsoft/vsts-agent/milestones{/number}","notifications_url":"https://api.github.com/repos/Microsoft/vsts-agent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Microsoft/vsts-agent/labels{/name}","releases_url":"https://api.github.com/repos/Microsoft/vsts-agent/releases{/id}","deployments_url":"https://api.github.com/repos/Microsoft/vsts-agent/deployments","created_at":"2016-03-03T13:36:48Z","updated_at":"2016-04-05T00:56:49Z","pushed_at":"2016-04-07T06:43:13Z","git_url":"git://github.com/Microsoft/vsts-agent.git","ssh_url":"git@github.com:Microsoft/vsts-agent.git","clone_url":"https://github.com/Microsoft/vsts-agent.git","svn_url":"https://github.com/Microsoft/vsts-agent","homepage":null,"size":656,"stargazers_count":20,"watchers_count":20,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":5,"forks":2,"open_issues":5,"watchers":20,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48"},"html":{"href":"https://github.com/Microsoft/vsts-agent/pull/48"},"issue":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/issues/48"},"comments":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/issues/48/comments"},"review_comments":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48/comments"},"review_comment":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/pulls/48/commits"},"statuses":{"href":"https://api.github.com/repos/Microsoft/vsts-agent/statuses/632ebf0a20d0f2cdc415149150e390284a92b916"}}}}