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.
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate