Skip to content

Instantly share code, notes, and snippets.

@OnurVar
Last active September 24, 2019 11:13
Show Gist options
  • Save OnurVar/7e8727b0f0584cd05713bac48abed725 to your computer and use it in GitHub Desktop.
Save OnurVar/7e8727b0f0584cd05713bac48abed725 to your computer and use it in GitHub Desktop.
Jenkins build clean command
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