Last active
May 14, 2018 21:55
-
-
Save null511/aedd7a1f64fafccb353313142af07f27 to your computer and use it in GitHub Desktop.
Get build number using Jenkins.NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; | |
Thread.Sleep(200); | |
} | |
return buildNumber.Value; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment