Hi, I'm trying to lock multiple stages in a pipeline and would like to use
NODE_NAME as the resource. Purpose is to allow multiple parallel executions
of the pipeline on different available nodes, but to make a node
unavailable while it's used by one running pipeline instance.
Now, the trick is that pipeline needs to be setup to run on two nodes at
the same time (please see example below).
I've tried setting it up by using lock in options block of the surrounding
stage, but since options gets evaluated/executed before agent is assigned
to a stage, this fails to find NODE_NAME.
pipeline {
agent none
stages {
stage ('main') {
parallel {
stage ('server') {
agent { label 'server' }
options { lock("${NODE_NAME}")} // This doesn't work. NODE_NAME not
available
steps {
script {
echo "${NODE_NAME}"
sleep(10)
}
}
}
stage ('client') {
agent { label 'client' }
options { lock("${NODE_NAME}")} // This doesn't work. NODE_NAME not
available
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/594a5949-a39b-4e24-a276-e932e8928c7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.