Issue
You want to delete all builds from a job, but not the ones that were promoted.
Environment
- CloudBees CI (CloudBees Core) on modern cloud platforms - Managed controller
- CloudBees CI (CloudBees Core) on traditional platforms - Client controller
- CloudBees Jenkins Enterprise - Managed controller
- CloudBees Jenkins Platform - Client controller
- CloudBees Jenkins Platform - Operations Center
- CloudBees Jenkins Distribution
- Jenkins LTS
Resolution
The following script run in the Jenkins script console at Manage Jenkins » Script Console does that. Note that you should always make sure to have good backups before deleting things like this in a script.
Jenkins.instance.getItemByFullName("yourJobNameHere").builds.each {
def p = it.getAction(hudson.plugins.promoted_builds.PromotedBuildAction)
if (!p || !p.hasPromotion()) {
it.delete()
}
}
return
Replace “yourJobNameHere” with the name of the job.
0 Comments