Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save arehmandev/c436e1a54118ac3087c5ff2f4b063c19 to your computer and use it in GitHub Desktop.
Save arehmandev/c436e1a54118ac3087c5ff2f4b063c19 to your computer and use it in GitHub Desktop.
Kill all queued jenkins jobs and cancel any running jobs
Jenkins.instance.getView('All').getBuilds().each { it.delete() }
import hudson.model.*
def q = Jenkins.instance.queue
// Cancel queued
q.items.each { q.cancel(it.task) }
// Stop running
Jenkins.instance.getView('All').getBuilds().findAll() { it.getResult().equals(null) }.each{
println("Stopping job ${it}")
it.doStop()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment