2020-02-10

How to discard or delete old builds in jenkins?

Jenkins provide list of internal plugin to manage build:
You can use options or properties in the pipeline to manage build.
pipeline {
  options {
    buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '30'))
  }
  ...
}
Or
pipeline(){
  properties ([
    buildDiscarder(logRotator(numToKeepStr: '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.



No comments:

Post a Comment