| Andrew Bayer, I'm trying to lock multiple stages based on the Jenkins node on which the stages will execute. It seems like the only way to do this is using the `options` block that you specified:
stage('Parent') {
options {
lock("${env.NODE_NAME}")
}
stages {
stage('first child') {
...
}
stage('second child') {
...
}
}
}
Unfortunately, the resource this attempts to lock is `null`:
Trying to acquire lock on [null]
It appears that this won't work because the stage's `options` directive occurs before entering the agent. The declarative pipeline syntax documentation says:
Inside a stage, the steps in the options directive are invoked before entering the agent or checking any when conditions.
Is there any way to lock multiple stages for a single env.NODE_NAME? Ideally, other subsequent stages could still run in parallel with other builds (i.e. so limiting executors to 1 or disabling concurrent builds are not options). |