How do I delete the builds 11 to 1717 in Jenkins?
Solution 1:
You have several options:
Temporarily set the number of builds to keep in the job configuration (Discard Old Builds) so that those builds will be deleted when the next build finishes. If the next build is 1800, set it to keep the most recent 85 or so. Mark all older builds (i.e. 1 to 10) as Keep This Build Forever before starting the next build. This option will fail to delete some builds if you have a downstream job that prevents upstream builds from being deleted (not a problem in your situation if all of them failed though).
-
Use the Script Console in Manage Jenkins. If it's a top level job (not in a folder), the following will do the trick:
Jenkins.instance.getItemByFullName('JobName').builds.findAll { it.number > 10 && it.number < 1717 }.each { it.delete() }
Of course, this approach generally requires good backups. There's a lot you can break using the script console.
Delete the builds' folders from disk (by default in
$JENKINS_HOME/jobs/JobName/builds/
, using the start time stamp as folder name) and restart Jenkins, or Reload Configuration From Disk. This option will not allow plugins that e.g. keep the SVN history in order by moving any changes to the subsequent build to do their job.
Solution 2:
Simply make an API call:
curl -X POST http://jenkinUser:[email protected]/job/theJob/[11-1717]/doDelete
To get the APIToken: login to Jenkins > Configuration > Show API Token.
Solution 3:
As Aaron stated correctly you can also use the Jenkins CLI for this purpose:
java -jar jenkins-cli.jar -s http://yourserver.com delete-builds <JobName> 11-1717