Skip to content

Instantly share code, notes, and snippets.

@stigkj
Created August 25, 2010 06:50
Show Gist options
  • Save stigkj/548986 to your computer and use it in GitHub Desktop.
Save stigkj/548986 to your computer and use it in GitHub Desktop.
Nice Groovy script for Hudson that checks which jobs are building or in the queue (got this from http://adrian.org.ar/ci/concurrency-in-hudson)
//Jobs currently building or in the queue
jobs = hudson.model.Hudson.instance.items.findAll{job -> job.isBuilding()} + hudson.model.Hudson.instance.items.findAll{job -> job.isInQueue()}
//Keep only the names from the collected job objects
jobs = jobs.collect{x -> x.name}
//get current job name
currentJob = Thread.currentThread().executable.toString().split()[0]
//cut current job from the jobs list
jobs -= currentJob
//decide if there is any running (or waiting) job
res = true
if ((jobs.size()) > 0)
{
res = false
println "The following jobs are being executed or waiting for an executor"
jobs.each{println it}
}
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment