Reputation: 705
I would like to monitor how many concurrent builds running for a job on Jenkins using groovy script console.
Using this I'm able to get the last build status. I need to get the count of current builds that are running. Can someone help me on this?
def item = hudson.model.Hudson.instance.getItem("<JOB-NAME>")
def build = item.getLastBuild()
println build.isInProgress()
Upvotes: 2
Views: 2131
Reputation: 4648
Try this:
jenkins.model.Jenkins.getInstance()
.getItem("<JOB-NAME>")
.getBuilds()
.findAll(
{
it.isInProgress()
}
).size()
Upvotes: 4