What does `lock` do and which plugin provides it?
IntermediateConceptDeclarative pipeline syntax
Answer
The Lockable Resources plugin provides lock, which serialises access to a named resource across all jobs: a shared test environment, a database, a device.
stage('Integration') {
options { lock(resource: 'staging-db') }
steps { sh './run-integration.sh' }
}
lock(label: 'test-env', quantity: 1, variable: 'ENV_NAME') picks one free resource from a pool and exposes its name. disableConcurrentBuilds only limits one job; lock works across jobs.
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate