Last active
February 16, 2020 14:11
-
-
Save diogopms/5d565ac27c4c42c0b7956002b5a66b55 to your computer and use it in GitHub Desktop.
jenkins clear all jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import jenkins.model.Jenkins | |
import hudson.model.Job | |
Jenkins.instance.allItems(Job).each { job -> | |
if (job.isBuildable() && job.supportsLogRotator() && job.getProperty(BuildDiscarderProperty) == null) { | |
def single_job = Jenkins.instance.getItem(job.fullDisplayName) | |
if(single_job != null) { | |
single_job.getBuilds().each { it.delete() } | |
single_job.nextBuildNumber = 1 | |
single_job.save() | |
println("OK: " + job.fullDisplayName) | |
} | |
else { | |
println("Error: " + job.fullDisplayName) | |
} | |
} | |
} | |
return; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment