-
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 } } }
[JENKINS-40966] Ability to leave Declarative node block w/ top-level agent for a single stage
Description |
Original:
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. {code:java|title=Jenkinsfile} pipeline { agent { label 'label' docker '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 } } } {code} 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. {code:java|title=Jenkinsfile with workaround} pipeline { agent none stages { lock(resource: 'resource', inversePrecedence:false) { stage('locked_staged') { agent 'label' steps { //do some work } } } stage('unlocked_stage') { steps { //work } } } {code} |
New:
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. {code:java|title=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 } } } {code} 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. {code:java|title=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 } } } {code} |
Priority | Original: Minor [ 4 ] | New: Critical [ 2 ] |
Summary | Original: Ability to lock portion of declarative pipeline without consuming node | New: Ability to leave Declarative node block w/ top-level agent for a single stage |
Epic Link |
New:
|
you can also use the node step directly in a stage to get an executor.