Skip to content

Instantly share code, notes, and snippets.

@sytsereitsma
Last active October 3, 2024 07:58
Show Gist options
  • Save sytsereitsma/1b370c558a4a34dfe014 to your computer and use it in GitHub Desktop.
Save sytsereitsma/1b370c558a4a34dfe014 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