Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ferblape/4f94556befffb237ca4ae16b51911c47 to your computer and use it in GitHub Desktop.
Save ferblape/4f94556befffb237ca4ae16b51911c47 to your computer and use it in GitHub Desktop.
[Jenkins] Clear build queue and cancel all builds
def q = Jenkins.instance.queue
q.items.findAll { q.cancel(it.task) }
//q.items.findAll { it.task.name.startsWith('my') }.each { q.cancel(it.task) }
def items = Jenkins.instance.items
items.each { job ->
job.builds.findAll { build -> build.building }.each { run ->
println("Aborting: " + job.name)
run.doStop();
}
}
println("Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment