-
Bug
-
Resolution: Unresolved
-
Major
Environments variables such as ${env.NODE_NAME} are not available in Options {} before stages. I want to dynamically lock a node using options {} before the first stage starts and keep that node locked for the entire pipeline.
I have spent hours on this everything I tried returns NULL. I know I can lock each stage individually but that won't work for me since it releases that lock at the end of each stage.
options {
lock (resource: "${env.NODE_NAME}")
}
stages {
stage("stage name") {
steps {.....
- is duplicated by
-
JENKINS-60367 Declarative Pipeline: Allow env vars to be used in options block
-
- Open
-
I use the options style lock to wrap a few stages in a large pipeline and I have the same problem. Even though the lock is deep within the pipeline, it seems the options are per-computed before the run and the ENV variables are not yet injected. For my use case - I would really like to use the `GIT_URL` provided by the multibranch pipeline project as the source of my lock. I don't mind multiple branches building at once, but there is a section they can't be in at the same time if they are on the same repo.
If you have a parameterized build - I believe parameters are available to the options blocks - but not environment variables.