Skip to content

Instantly share code, notes, and snippets.

View null511's full-sized avatar

Joshua Miller null511

  • Equifax
  • South Carolina, US
View GitHub Profile
@null511
null511 / JenkinsNet_GetBuildNumber.cs
Last active May 14, 2018 21:55
Get build number using Jenkins.NET
// Enqueue a new build and get queue #
JenkinsBuildResult buildResult = client.Jobs.Build(jobName);
int? queueItemNumber = buildResult.GetQueueItemNumber();
// Poll queue item until build number is available
int? buildNumber = null;
while (!buildNumber.HasValue) {
var queueItem = client.Queue.GetItem(queueItemNumber.Value);
buildNumber = queueItem?.Executable?.Number;
if (buildNumber.HasValue) break;