private Task DownloadPipelineArtifacts(
            BuildDropManager buildDropManager,
            IEnumerable <BuildArtifact> buildArtifacts,
            string targetDirectory,
            string[] minimatchFilters,
            CancellationToken cancellationToken)
        {
            IDictionary <string, DedupIdentifier> artifactNameAndManifestId = new Dictionary <string, DedupIdentifier>();

            foreach (var buildArtifact in buildArtifacts)
            {
                if (buildArtifact.Resource.Type != PipelineArtifactTypeName)
                {
                    throw new ArgumentException("The artifact is not of the type Pipeline Artifact.");
                }
                artifactNameAndManifestId.Add(buildArtifact.Name, DedupIdentifier.Create(buildArtifact.Resource.Data));
            }

            // 2) download to the target path
            DownloadPipelineArtifactOptions options = DownloadPipelineArtifactOptions.CreateWithMultiManifestIds(
                artifactNameAndManifestId,
                targetDirectory,
                proxyUri: null,
                minimatchPatterns: minimatchFilters);

            return(buildDropManager.DownloadAsync(options, cancellationToken));
        }
Beispiel #2
0
        // Download pipeline artifact from VSTS BlobStore service through BuildDropManager to a target path
        internal async Task DownloadAsync(
            AgentTaskPluginExecutionContext context,
            Guid projectId,
            int buildId,
            string artifactName,
            string targetDir,
            CancellationToken cancellationToken)
        {
            VssConnection connection = context.VssConnection;

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

            var manifestId = DedupIdentifier.Create(art.Resource.Data);

            // 2) download to the target path
            var httpclient = connection.GetClient <DedupStoreHttpClient>();
            var tracer     = new CallbackAppTraceSource(str => context.Output(str), System.Diagnostics.SourceLevels.Information);

            httpclient.SetTracer(tracer);
            var client           = new DedupStoreClientWithDataport(httpclient, maxParallelism: 16 * Environment.ProcessorCount);
            var BuildDropManager = new BuildDropManager(client, tracer);
            await BuildDropManager.DownloadAsync(manifestId, targetDir, cancellationToken);
        }
Beispiel #3
0
        // Upload from target path to VSTS BlobStore service through BuildDropManager, then associate it with the build
        internal async Task UploadAsync(
            AgentTaskPluginExecutionContext context,
            Guid projectId,
            int buildId,
            string name,
            string source,
            CancellationToken cancellationToken)
        {
            VssConnection connection = context.VssConnection;

            // 1) upload pipeline artifact to VSTS BlobStore
            var httpclient = connection.GetClient <DedupStoreHttpClient>();
            var tracer     = new CallbackAppTraceSource(str => context.Output(str), System.Diagnostics.SourceLevels.Information);

            httpclient.SetTracer(tracer);
            var client           = new DedupStoreClientWithDataport(httpclient, 16 * Environment.ProcessorCount);
            var BuildDropManager = new BuildDropManager(client, tracer);
            var result           = await BuildDropManager.PublishAsync(source, cancellationToken);

            // 2) associate the pipeline artifact with an build artifact
            BuildServer buildHelper = new BuildServer(connection);
            Dictionary <string, string> propertiesDictionary = new Dictionary <string, string>();

            propertiesDictionary.Add(RootId, result.RootId.ValueString);
            propertiesDictionary.Add(ProofNodes, StringUtil.ConvertToJson(result.ProofNodes.ToArray()));
            var artifact = await buildHelper.AssociateArtifact(projectId, buildId, name, ArtifactResourceTypes.PipelineArtifact, result.ManifestId.ValueString, propertiesDictionary, cancellationToken);

            context.Output(StringUtil.Loc("AssociateArtifactWithBuild", artifact.Id, buildId));
        }
Beispiel #4
0
        public PipelineArtifactProvider(AgentTaskPluginExecutionContext context, VssConnection connection, CallbackAppTraceSource tracer)
        {
            var dedupStoreHttpClient = connection.GetClient <DedupStoreHttpClient>();

            this.tracer = tracer;
            dedupStoreHttpClient.SetTracer(tracer);
            var client = new DedupStoreClientWithDataport(dedupStoreHttpClient, 16 * Environment.ProcessorCount);

            buildDropManager = new BuildDropManager(client, this.tracer);
        }
Beispiel #5
0
        private BuildDropManager CreateBulidDropManager(AgentTaskPluginExecutionContext context, VssConnection connection)
        {
            var dedupStoreHttpClient = connection.GetClient <DedupStoreHttpClient>();
            var tracer = this.CreateTracer(context);

            dedupStoreHttpClient.SetTracer(tracer);
            var client           = new DedupStoreClientWithDataport(dedupStoreHttpClient, 16 * Environment.ProcessorCount);
            var buildDropManager = new BuildDropManager(client, tracer);

            return(buildDropManager);
        }
        private BuildDropManager CreateBulidDropManager(AgentTaskPluginExecutionContext context, VssConnection connection)
        {
            var dedupStoreHttpClient = connection.GetClient <DedupStoreHttpClient>();
            var tracer = new CallbackAppTraceSource(str => context.Output(str), System.Diagnostics.SourceLevels.Information);

            dedupStoreHttpClient.SetTracer(tracer);
            var client           = new DedupStoreClientWithDataport(dedupStoreHttpClient, 16 * Environment.ProcessorCount);
            var buildDropManager = new BuildDropManager(client, tracer);

            return(buildDropManager);
        }
        private BuildDropManager CreateBulidDropManager(AgentTaskPluginExecutionContext context, VssConnection connection)
        {
            var dedupStoreHttpClient = connection.GetClient <DedupStoreHttpClient>();
            var tracer = this.CreateTracer(context);

            dedupStoreHttpClient.SetTracer(tracer);
            var client           = new DedupStoreClientWithDataport(dedupStoreHttpClient, PipelineArtifactProvider.GetDedupStoreClientMaxParallelism(context));
            var buildDropManager = new BuildDropManager(client, tracer);

            return(buildDropManager);
        }
        public PipelineArtifactProvider(AgentTaskPluginExecutionContext context, VssConnection connection, CallbackAppTraceSource tracer)
        {
            var dedupStoreHttpClient = connection.GetClient <DedupStoreHttpClient>();

            this.tracer = tracer;
            dedupStoreHttpClient.SetTracer(tracer);
            int parallelism = GetDedupStoreClientMaxParallelism(context);
            var client      = new DedupStoreClientWithDataport(dedupStoreHttpClient, parallelism);

            buildDropManager = new BuildDropManager(client, this.tracer);
        }
        private Task DownloadPipelineArtifact(
            BuildDropManager buildDropManager,
            BuildArtifact buildArtifact,
            string targetDirectory,
            string[] minimatchFilters,
            CancellationToken cancellationToken)
        {
            if (buildArtifact.Resource.Type != PipelineArtifactTypeName)
            {
                throw new ArgumentException("The artifact is not of the type Pipeline Artifact.");
            }
            var manifestId = DedupIdentifier.Create(buildArtifact.Resource.Data);

            // 2) download to the target path
            DownloadPipelineArtifactOptions options = DownloadPipelineArtifactOptions.CreateWithManifestId(
                manifestId,
                targetDirectory,
                proxyUri: null,
                minimatchPatterns: minimatchFilters);

            return(buildDropManager.DownloadAsync(options, cancellationToken));
        }