简体   繁体   中英

Jenkins: Deleting Old Builds

How to delete old Jenkins builds manually? I used Discard Old Builds plugin and set to keep last 10 builds. It is not working perfectly and keeping 13 builds. Is there any proper way even to do it manually so that build numbers [#1 #2 ...etc] will also be reorganised?

If you don't mind scripting the deletion algorithm yourself, you can easily create something in Groovy Postbuild .

For example, if you wanted to keep the last 10 builds and delete the rest, copy and paste this one liner in the groovy postbuild step:

manager.build.parent.builds.drop(10).each { it.delete() }

What's good about this approach is that you have full control over how things are deleted. For example, you could easily do something fancy like delete builds based on a logarithmic approach with older builds dropping off faster than newer ones.

Other than setting up "max number of builds to keep". There's a "delete this build option" associated with every build when you click on them, but you need to have admin privilege to delete it. Another way to do it is, from the server. Go to the directory where builds are archived and remove them. Path looks like below.

$JENKINS_HOME/jobs/<jobname>/builds

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM