Skip to main content

Posts

Showing posts with the label discardOldBuild

How to discard Jenkins old builds from project or Pipeline?

When we work with Jenkins, we surely run our project(s) multiple times and this will result in a long queue of the build History list that mostly is of no use after certain numbers. How to discard Jenkins old builds from project or Pipeline? 1) If you have access to the " Manage Jenkins " section of your Jenkins then you can run the below-mentioned script to clean your project Build History. Note* This will reset the build number to 1 on your next run. a) Access your Jenkins HP > Manage Jenkins > Script Console b) Copy-Paste this script to your Console Script text area and update the " myproject_name " with your project name where you need to clean the build history and hit the " Run button ". def yourJobName = "myproject_name" def job = Jenkins.instance.getItem(yourJobName) job.getBuilds().each { it.delete() } job.nextBuildNumber = 1 job.save() This should clean your Build History for that particular project but if you&