Last active
September 24, 2019 11:13
-
-
Save OnurVar/7e8727b0f0584cd05713bac48abed725 to your computer and use it in GitHub Desktop.
Jenkins build clean command
This file contains hidden or 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
Jenkins.instance.getAllItems(AbstractProject.class).each { project -> | |
def jobName = project.fullName | |
def job = Jenkins.instance.getItemByFullName(jobName) | |
if (job) { | |
println("Found Job : ${job.name}"); | |
job.getBuilds().each { build -> | |
println("- Deleting #${build.number}"); | |
build.delete() | |
} | |
job.nextBuildNumber = 302 | |
job.save() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment