Exemplo n.º 1
0
 /// <summary>
 /// Gets information describing a Jenkins Job Build.
 /// </summary>
 /// <param name="jobName">The name of the Job.</param>
 /// <param name="buildNumber">The number of the build.</param>
 /// <exception cref="JenkinsJobGetBuildException"></exception>
 public T Get <T>(string jobName, string buildNumber) where T : class, IJenkinsBuild
 {
     try {
         var cmd = new BuildGetCommand <T>(context, jobName, buildNumber);
         cmd.Run();
         return(cmd.Result);
     }
     catch (Exception error) {
         throw new JenkinsJobGetBuildException($"Failed to retrieve build #{buildNumber} of Jenkins Job '{jobName}'!", error);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Gets information describing a Jenkins Job Build asynchronously.
        /// </summary>
        /// <param name="jobName">The name of the Job.</param>
        /// <param name="buildNumber">The number of the build.</param>
        /// <param name="token">An optional token for aborting the request.</param>
        /// <exception cref="JenkinsJobGetBuildException"></exception>
        public async Task <T> GetAsync <T>(string jobName, string buildNumber, CancellationToken token = default(CancellationToken)) where T : class, IJenkinsBuild
        {
            try {
                var cmd = new BuildGetCommand <T>(context, jobName, buildNumber);
                await cmd.RunAsync(token);

                return(cmd.Result);
            }
            catch (Exception error) {
                throw new JenkinsJobGetBuildException($"Failed to retrieve build #{buildNumber} of Jenkins Job '{jobName}'!", error);
            }
        }