Disabling 'Keep this build forever' on job

81 views
Skip to first unread message

Sean Jones

unread,
Nov 5, 2015, 11:49:08 AM11/5/15
to Jenkins Users
I have a large matrix configuration. Each configuration is storing ~5GB of data and I only need to keep a few builds at any one time, so I have enabled log rotator to keep 5 builds.

I can't seem to find a setting or option to completely disable the 'Keep this build forever'. This is quickly filling up the Jenkins job store. Is there an option to disable this or am I doomed to delete artefacts manually?

Björn Pedersen

unread,
Nov 5, 2015, 12:14:24 PM11/5/15
to Jenkins Users
You can use the groovy postbuild plugin for un-keeping:

for(i=1; i<currentBuildNumber; i++) {
    if(manager.setBuildNumber(i)) {
                 manager.removeBadge(0)
                 manager.addWarningBadge('unkept')
                 manager.build.keepLog(false)

Björn Pedersen

unread,
Nov 5, 2015, 12:16:12 PM11/5/15
to Jenkins Users
Or more efficient:

job.builds.findAll{it != currentBuild && it.isKeepLog(){
      manager.setBuildNumber(it.number)

      manager.removeBadge(0)
      manager.addWarningBadge('unkept')
      manager.build.keepLog(false)
}

Am Donnerstag, 5. November 2015 17:49:08 UTC+1 schrieb Sean Jones:
Reply all
Reply to author
Forward
0 new messages