Best Strategy for Disk Space Management: Clean Up Old Builds Bee Bot July 13, 2022 10:21 Updated The content of this article has moved to the new documentation site. Related articles Groovy to list all jobs How to troubleshoot 'no space left on device' errors in Linux JobConfigHistory Plugin Best Practices How can I purge/clean the build queue? Global Build Discarders causes exceptions after Upgrading to 2.222.x Comments 2 comments Sort by Date Votes 邵彬 Please Update September 20, 2018 08:54 Manage Jenkins -> Script Console def jobName = "Some_Job_Name" def maxNumber = 64 Jenkins.instance.getItemByFullName(jobName).builds.findAll { it.number <= maxNumber }.each { it.delete() } HOW TO CLEAN AND RESET JENKINS BUILD HISTORY How do I delete the builds 11 to 1717 in Jenkins? Deleting Old Builds - Best Strategy for Cleanup and disk space management -2 Jaydeep Dave June 14, 2019 16:58 How about this: def daysToKeep = 30def numToKeep = 10def artifactDaysToKeep = -1def artifactNumToKeep = -1Jenkins.instance.getAllItems(AbstractItem.class).each { println("=====================") println("JOB: " + it.name) println("Job type: " + it.getClass()) if (it instanceof org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject) { try { orpStrategy = new com.cloudbees.hudson.plugins.folder.computed.DefaultOrphanedItemStrategy(true, daysToKeep, numToKeep) it.setOrphanedItemStrategy(orpStrategy) it.save() println("") }catch(Exception e) {} } if (it instanceof org.jenkinsci.plugins.workflow.job.WorkflowJob) { try { it.buildDiscarder = new hudson.tasks.LogRotator(daysToKeep,numToKeep, artifactDaysToKeep, artifactNumToKeep) it.save() println("") }catch(Exception e) {} }}; 2 Please sign in to leave a comment.
Comments
2 comments
Manage Jenkins -> Script Console
How about this:
Please sign in to leave a comment.