The groovy syntax generator is NOT working for sample step properties: Set Job Properties
. I've selected Discard old builds
and then entered 10
in the Max # of builds to keep
field and then Generate Groovy
and nothing shows up.
Jenkins version: 2.7
Delete a Jenkins build via GUI. Go into the build you want to delete, and click the Delete this build button in the upper right corner. If you need to clean the Jenkins build history, and reset the build number back to 1, you can run a simple script in Jenkins Script Console.
This is a feature that is given to you by Jenkins so you can change the number of builds you want to keep. If you are using a Declarative pipeline you can just add this to your code: pipeline { options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30')) } ... }
There's a lot you can break using the script console. Delete the builds' folders from disk (by default in $JENKINS_HOME/jobs/JobName/builds/ , using the start time stamp as folder name) and restart Jenkins, or Reload Configuration From Disk.
As for declarative syntax, you can use the options
block:
pipeline { options { buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30')) } ... }
Parameters for logRotator
(from the source code):
daysToKeepStr
: history is only kept up to this days.numToKeepStr
: only this number of build logs are kept.artifactDaysToKeepStr
: artifacts are only kept up to this days.artifactNumToKeepStr
: only this number of builds have their artifacts kept.More information can be found in Cloudbees knowledge base and in the docs for options
block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With