private async Task DownloadArtifacts(
            IExecutionContext executionContext,
            Guid teamProjectId,
            string artifactsWorkingFolder,
            int releaseId)
        {
            Trace.Entering();

            ServiceEndpoint vssEndpoint = executionContext.Endpoints.FirstOrDefault(e => string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));

            ArgUtil.NotNull(vssEndpoint, nameof(vssEndpoint));
            ArgUtil.NotNull(vssEndpoint.Url, nameof(vssEndpoint.Url));

            Trace.Info($"Connecting to {vssEndpoint.Url}/{teamProjectId}");
            var releaseServer = new ReleaseServer(vssEndpoint.Url, ApiUtil.GetVssCredential(vssEndpoint), teamProjectId);

            // TODO: send correct cancellation token
            List <AgentArtifactDefinition> releaseArtifacts = releaseServer.GetReleaseArtifactsFromService(releaseId).ToList();
            var filteredReleaseArtifacts = FilterArtifactDefintions(releaseArtifacts);

            filteredReleaseArtifacts.ToList().ForEach(x => Trace.Info($"Found Artifact = {x.Alias} of type {x.ArtifactType}"));

            CleanUpArtifactsFolder(executionContext, artifactsWorkingFolder);
            await DownloadArtifacts(executionContext, filteredReleaseArtifacts, artifactsWorkingFolder);
        }
Beispiel #2
0
        private async Task GetArtifactsAsync(IExecutionContext executionContext)
        {
            Trace.Entering();

            try
            {
                ServiceEndpoint vssEndpoint = executionContext.Endpoints.FirstOrDefault(e => string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
                ArgUtil.NotNull(vssEndpoint, nameof(vssEndpoint));
                ArgUtil.NotNull(vssEndpoint.Url, nameof(vssEndpoint.Url));

                Trace.Info($"Connecting to {vssEndpoint.Url}/{TeamProjectId}");
                var releaseServer = new ReleaseServer(vssEndpoint.Url, ApiUtil.GetVssCredential(vssEndpoint), TeamProjectId);

                IList <AgentArtifactDefinition> releaseArtifacts         = releaseServer.GetReleaseArtifactsFromService(ReleaseId).ToList();
                IList <AgentArtifactDefinition> filteredReleaseArtifacts = FilterArtifactDefintions(releaseArtifacts);
                filteredReleaseArtifacts.ToList().ForEach(x => Trace.Info($"Found Artifact = {x.Alias} of type {x.ArtifactType}"));

                if (!SkipArtifactsDownload)
                {
                    // 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
                    executionContext.Output(StringUtil.Loc("RMDownloadingArtifact"));
                    await DownloadArtifacts(executionContext, filteredReleaseArtifacts, ArtifactsWorkingFolder);
                }

                executionContext.Output(StringUtil.Loc("RMDownloadingCommits"));
                await DownloadCommits(executionContext, TeamProjectId, releaseArtifacts);
            }
            catch (Exception ex)
            {
                LogDownloadFailureTelemetry(executionContext, ex);
                throw;
            }
        }
Beispiel #3
0
        private async Task UpdateReleaseNameAsync(
            IAsyncCommandContext commandContext,
            IExecutionContext context,
            VssConnection connection,
            Guid projectId,
            string releaseId,
            string releaseName,
            CancellationToken cancellationToken)
        {
            ReleaseServer releaseServer = new ReleaseServer(connection, projectId);
            var           release       = await releaseServer.UpdateReleaseName(releaseId, releaseName, cancellationToken);

            commandContext.Output(StringUtil.Loc("RMUpdateReleaseNameForRelease", release.Name, release.Id));
            context.Variables.Set("release.releaseName", release.Name);
        }
Beispiel #4
0
        private IList <AgentArtifactDefinition> GetReleaseArtifacts(IExecutionContext executionContext)
        {
            try
            {
                var connection    = WorkerUtilities.GetVssConnection(executionContext);
                var releaseServer = new ReleaseServer(connection, TeamProjectId);

                IList <AgentArtifactDefinition> releaseArtifacts         = releaseServer.GetReleaseArtifactsFromService(ReleaseId).ToList();
                IList <AgentArtifactDefinition> filteredReleaseArtifacts = FilterArtifactDefintions(releaseArtifacts);
                filteredReleaseArtifacts.ToList().ForEach(x => Trace.Info($"Found Artifact = {x.Alias} of type {x.ArtifactType}"));
                return(filteredReleaseArtifacts);
            }
            catch (Exception ex)
            {
                LogDownloadFailureTelemetry(executionContext, ex);
                throw;
            }
        }
Beispiel #5
0
        private IList <AgentArtifactDefinition> GetReleaseArtifacts(IExecutionContext executionContext)
        {
            try
            {
                ServiceEndpoint vssEndpoint = executionContext.Endpoints.FirstOrDefault(e =>
                                                                                        string.Equals(e.Name, ServiceEndpoints.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
                ArgUtil.NotNull(vssEndpoint, nameof(vssEndpoint));
                ArgUtil.NotNull(vssEndpoint.Url, nameof(vssEndpoint.Url));

                Trace.Info($"Connecting to {vssEndpoint.Url}/{TeamProjectId}");
                var releaseServer = new ReleaseServer(vssEndpoint.Url, ApiUtil.GetVssCredential(vssEndpoint), TeamProjectId);

                IList <AgentArtifactDefinition> releaseArtifacts         = releaseServer.GetReleaseArtifactsFromService(ReleaseId).ToList();
                IList <AgentArtifactDefinition> filteredReleaseArtifacts = FilterArtifactDefintions(releaseArtifacts);
                filteredReleaseArtifacts.ToList().ForEach(x => Trace.Info($"Found Artifact = {x.Alias} of type {x.ArtifactType}"));
                return(releaseArtifacts);
            }
            catch (Exception ex)
            {
                LogDownloadFailureTelemetry(executionContext, ex);
                throw;
            }
        }