Reputation: 171
Is there any plugin or script to remove old build data from Jenkins? There are docker images associated with the builds, so they are taking lots of space. I don't want to keep the build data for more than 30 days.
Seen this plugin : Jenkins: remove old builds But it seems buggy and many people faced problems with it
Upvotes: 1
Views: 3155
Reputation: 432
I have used several of the of Groovy Jenkins scriptlets described here: https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler
Search for 'bulk' and you'll find several flavors. My favorite is https://github.com/jenkinsci/jenkins-scripts/blob/master/scriptler/bulkDeleteBuilds.groovy which allows you to delete job builds in a specified range.
You can run scriptlets automatically as part of a build, or for more control manually from the Scriptlet console or even from a chron Jenkins job.
Upvotes: 0
Reputation: 1648
I would suggest sticking with the plugin as you already figured out. It works well for me to get rid of old builds and associated artifacts (archive step).
Have a look at the various parameters you can set with it- https://jenkinsci.github.io/job-dsl-plugin/#path/pipelineJob-logRotator
In your case - setting "daysToKeep" to 30 should do
Be aware It will not remove the docker images; for that, you need to implement separate strategy; say 'docker system prune" or "docker image prune"
check this - https://docs.docker.com/engine/reference/commandline/image_prune/
Upvotes: 1