Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bratucornel/ed700212a79debe4b1990c97f2095d6a to your computer and use it in GitHub Desktop.
Save bratucornel/ed700212a79debe4b1990c97f2095d6a to your computer and use it in GitHub Desktop.
Cancel all running Jenkins builds with system groovy script
import jenkins.model.Jenkins
def numCancels = 0;
Jenkins.instance.getAllItems(Job.class).each{
def job = it
for (build in job.builds) {
if (build.isBuilding()) { build.doStop(); numCancels++; }
}
}
println("${numCancels}");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment