コード例 #1
0
 // Get named artifact from a build
 public async Task <BuildArtifact> GetArtifact(
     Guid projectId,
     int pipelineId,
     string name,
     CancellationToken cancellationToken)
 {
     return(await _buildHttpClient.GetArtifactAsync(projectId, pipelineId, name, cancellationToken : cancellationToken));
 }
コード例 #2
0
        /// <summary>
        /// Download a build content
        /// </summary>
        /// <param name="StartedBuild"></param>
        /// <param name="ArtifactName"></param>
        private static void DownloadBuildResults(Build StartedBuild, string ArtifactName)
        {
            BuildArtifact drop = BuildClient.GetArtifactAsync(StartedBuild.Id, ArtifactName).Result; //get detiled info

            Console.WriteLine("Build location: " + drop.Resource.DownloadUrl);

            string dropFileName = String.Format("{0}_{1}.zip", StartedBuild.Definition.Name, StartedBuild.BuildNumber);

            Stream zipStream = BuildClient.GetArtifactContentZipAsync(StartedBuild.Id, ArtifactName).Result; //get content

            using (FileStream zipFile = new FileStream(dropFileName, FileMode.Create))
                zipStream.CopyTo(zipFile);

            Console.WriteLine("The file '{0}' has been downloaded.", dropFileName);
        }