-
New Feature
-
Resolution: Unresolved
-
Major
-
None
-
pipeline-model-definition 0.8.1
I have a use case where I'd like to have a specific section of the pipeline limited to one concurrent step across all pipeline instances.
Jenkinsfile
pipeline { agent { docker { label 'label' image 'image' } } stages { stage('locked_staged') { steps { //do some work lock(resource: 'resource', inversePrecedence:false) { //do locked work } //do more work } } stage('unlocked_stage') { steps { //work } } }
This example would consume a node for the entire pipeline. Any node hitting the lock stage would current be blocked waiting on the lock. I would like for the node to be released once the lock is hit and resume once available.
There is a partial workaround by specifically declaring agent at the appropriate stage.
Jenkinsfile with workaround
pipeline { agent none stages { stage('locked_staged') { agent 'label' steps { lock(resource: 'resource', inversePrecedence:false) { //do some work } } } stage('unlocked_stage') { steps { //work } } }