Skip to content

Instantly share code, notes, and snippets.

@carlos-jenkins
Last active October 3, 2019 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlos-jenkins/4340bfd0c9703b3896df3d8bf344b189 to your computer and use it in GitHub Desktop.
Save carlos-jenkins/4340bfd0c9703b3896df3d8bf344b189 to your computer and use it in GitHub Desktop.
Jenkins script to get job queues
import groovy.json.JsonOutput
result = []
Jenkins.instance.queue.items.each {
// Only consider BuildableItem
// Other known objects are:
// - BlockedItem, which lacks the runId
if (it instanceof Queue.BuildableItem) {
result.add([
name: it.task.runId,
id: it.id,
why: it.why,
startTime: it.inQueueSince,
])
}
}
print(JsonOutput.toJson(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment