Created
December 28, 2017 09:36
-
-
Save tizki/dbf5c9db93de3d8cfa73da39d600ca8f to your computer and use it in GitHub Desktop.
The following script prints the time each build spent in the queue
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
def jenkins = Jenkins.instance | |
def jobName = PUT_YOUR_JOB_NAME | |
def job = jenkins.getItem(jobName) | |
def builds = job.getBuilds() | |
builds.each { build -> | |
def action = build.getAction(jenkins.metrics.impl.TimeInQueueAction.class) | |
def timeInQ = action.getQueuingDurationMillis() | |
def totalTimeInQ | |
if (timeInQ > 60000){ | |
totalTimeInQ = "${timeInQ / 60000} minutes" | |
} | |
else{ | |
totalTimeInQ = "${timeInQ / 1000} seconds" | |
} | |
println "${build.number} ${totalTimeInQ}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment