Mahbub Rahman
Mahbub Rahman

Reputation: 1343

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?

Upvotes: 3

Views: 4020

Answers (2)

Daniel Omoto
Daniel Omoto

Reputation: 2481

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.

Upvotes: 2

xCodeZone
xCodeZone

Reputation: 194

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

Upvotes: 0

Related Questions