-
Notifications
You must be signed in to change notification settings - Fork 196
Description
What feature do you want to see added?
Heya,
similar to #685 I've been trying to lock some stages based on dynamic values (the env.NODE_NAME)
unfortunately Jenkins seems to evaluate the parameters before the node exists, so the lock creation fails
pipeline {
agent any
stages {
stage('top stage') {
options {
lock(env.NODE_NAME)
}
stages {
stage('test') {
steps {
echo "test"
sh 'sleep 30'
}
}
stage('cleanup') {
steps {
echo "cleanup"
}
}
}
}
}
}The annoying part is that the lock seems to be executed when the stage starts, so after node provisioning, but it seems impossible to inject a variable at that time that's not known during build start.
For additional context: our nodes are created dynamically so it's not possible to know the name ahead of time and if I ask our devs to start adding scripted pipelines on top of their declarative ones I'm afraid they'll throw their keyboards at me, so that doesn't seem like a good solution either.
Is there a known workaround, or would it be possible to add an argument to use the current node as resource name?
Thanks!
Upstream changes
No response
Are you interested in contributing this feature?
I'd be happy to but I wouldn't even know where to start