Esempio n. 1
0
        // Download pipeline artifact with project name.
        internal async Task DownloadAsyncWithProjectNameMiniMatch(
            AgentTaskPluginExecutionContext context,
            string project,
            int buildId,
            string artifactName,
            string targetDir,
            string[] minimatchFilters,
            CancellationToken cancellationToken)
        {
            VssConnection connection = context.VssConnection;

            // 1) get manifest id from artifact data
            BuildServer   buildHelper = new BuildServer(connection);
            BuildArtifact art         = await buildHelper.GetArtifactWithProjectAsync(project, buildId, artifactName, cancellationToken);

            if (art.Resource.Type != "PipelineArtifact")
            {
                throw new ArgumentException("The artifact is not of the type Pipeline Artifact\n");
            }
            var manifestId = DedupIdentifier.Create(art.Resource.Data);

            // 2) download to the target path
            var buildDropManager = this.GetBDM(context, connection);
            DownloadPipelineArtifactOptions options = DownloadPipelineArtifactOptions.CreateWithManifestId(manifestId, targetDir, proxyUri: null, minimatchPatterns: minimatchFilters);
            await buildDropManager.DownloadAsync(options, cancellationToken);
        }