What does `options { }` do in a declarative pipeline?

IntermediateConceptJenkins
Answer

options sets pipeline-level behaviour. The ones I use on every pipeline: timeout, buildDiscarder, disableConcurrentBuilds, timestamps, skipDefaultCheckout, and retry.

options {
  timeout(time: 30, unit: 'MINUTES')
  buildDiscarder(logRotator(numToKeepStr: '30', artifactNumToKeepStr: '5'))
  disableConcurrentBuilds(abortPrevious: true)
  timestamps()
}

Without buildDiscarder the controller disk eventually fills with old builds.

All CI/CD questions

More on Jenkins