Exemple #1
0
 /// <summary>
 /// Retrieves an artifact from a completed Job.
 /// </summary>
 /// <param name="jobName">The name of the Job.</param>
 /// <param name="buildNumber">The build number of the Job.</param>
 /// <param name="filename">The relative path and file name of the artifact.</param>
 /// <returns>A memory-stream containing the contents of the artifact.</returns>
 /// <exception cref="JenkinsArtifactGetException"></exception>
 public MemoryStream Get(string jobName, string buildNumber, string filename)
 {
     try {
         var cmd = new ArtifactGetCommand(context, jobName, buildNumber, filename);
         cmd.Run();
         return(cmd.Result);
     }
     catch (Exception error) {
         throw new JenkinsArtifactGetException($"Failed to retrieve artifact '{filename}'!", error);
     }
 }
Exemple #2
0
        /// <summary>
        /// Retrieves an artifact from a completed Job asynchronously.
        /// </summary>
        /// <param name="jobName">The name of the Job.</param>
        /// <param name="buildNumber">The build number of the Job.</param>
        /// <param name="filename">The relative path and file name of the artifact.</param>
        /// <param name="token">An optional token for aborting the request.</param>
        /// <returns>A memory-stream containing the contents of the artifact.</returns>
        /// <exception cref="JenkinsArtifactGetException"></exception>
        public async Task <MemoryStream> GetAsync(string jobName, string buildNumber, string filename, CancellationToken token = default(CancellationToken))
        {
            try {
                var cmd = new ArtifactGetCommand(context, jobName, buildNumber, filename);
                await cmd.RunAsync(token);

                return(cmd.Result);
            }
            catch (Exception error) {
                throw new JenkinsArtifactGetException($"Failed to retrieve artifact '{filename}'!", error);
            }
        }