Hi, 
I'm trying to figure out how/if it's possible to create a lock that will 
guard multiple stages of a pipeline execution, based on the NODE_NAME on 
which they are supposed to execute.

I tried putting the lock in the options block of the surrounding stage, but 
this throws an error because options block in a stage is executed/evaluated 
before agent block.
Please see the example pipeline below for reference:

pipeline {
agent none
stages {
stage ('main') {
parallel {
stage ('server') {
agent { label 'server' }
// options { lock(NODE_NAME) }
stages {
stage ('all') {
options { lock("${NODE_NAME}") } // this also seems to fail
steps {
script {
echo "${NODE_NAME}"
sleep(10)
}
}
}
}
}
stage ('client') {
agent { label 'client' }
stages {
stage ('all') {
options { lock("${NODE_NAME}") }
steps {
script {
echo "${NODE_NAME}"
sleep(10)
}
}
}
}
}
}
}
}
}

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/6d488fc9-333b-4d30-93f0-4fa59c7769fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to