Environment variables for properties are always indexed
Jenkins and plugins versions report
Environment
Jenkins: 2.411
OS: Linux - 6.3.8-100.fc37.x86_64
Java: 11.0.19 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
apache-httpcomponents-client-4-api:4.5.14-150.v7a_b_9d17134a_5
bootstrap5-api:5.3.0-1
bouncycastle-api:2.28
branch-api:2.1109.vdf225489a_16d
caffeine-api:3.1.6-115.vb_8b_b_328e59d8
checks-api:2.0.0
cloudbees-folder:6.815.v0dd5a_cb_40e0e
commons-lang3-api:3.12.0-36.vd97de6465d5b_
commons-text-api:1.10.0-36.vc008c8fcda_7b_
credentials:1254.vb_96f366e7b_a_d
credentials-binding:604.vb_64480b_c56ca_
data-tables-api:1.13.4-3
display-url-api:2.3.7
durable-task:507.v050055d0cb_dd
echarts-api:5.4.0-5
font-awesome-api:6.4.0-1
git:5.1.0
git-client:4.4.0
instance-identity:173.va_37c494ec4e5
ionicons-api:56.v1b_1c8c49374e
jackson2-api:2.15.2-350.v0c2f3f8fc595
jakarta-activation-api:2.0.1-3
jakarta-mail-api:2.0.1-3
javax-activation-api:1.2.0-6
javax-mail-api:1.6.2-9
jaxb:2.3.8-1
jquery3-api:3.7.0-1
junit:1214.va_2f9db_3e6de0
lockable-resources:1172.v4b_8fc8eed570
mailer:457.v3f72cb_e015e5
matrix-project:789.v57a_725b_63c79
mina-sshd-api-common:2.10.0-69.v28e3e36d18eb_
mina-sshd-api-core:2.10.0-69.v28e3e36d18eb_
pipeline-build-step:496.v2449a_9a_221f2
pipeline-groovy-lib:656.va_a_ceeb_6ffb_f7
pipeline-input-step:468.va_5db_051498a_4
pipeline-milestone-step:111.v449306f708b_7
pipeline-model-api:2.2141.v5402e818a_779
pipeline-model-definition:2.2141.v5402e818a_779
pipeline-model-extensions:2.2141.v5402e818a_779
pipeline-stage-step:305.ve96d0205c1c6
pipeline-stage-tags-metadata:2.2141.v5402e818a_779
plain-credentials:143.v1b_df8b_d3b_e48
plugin-util-api:3.3.0
scm-api:676.v886669a_199a_a_
script-security:1251.vfe552ed55f8d
snakeyaml-api:1.33-95.va_b_a_e3e47b_fa_4
ssh-credentials:305.v8f4381501156
structs:324.va_f5d6774f3a_d
trilead-api:2.84.v72119de229b_7
variant:59.vf075fe829ccb
workflow-aggregator:596.v8c21c963d92d
workflow-api:1215.v2b_ee3e1b_dd39
workflow-basic-steps:1017.vb_45b_302f0cea_
workflow-cps:3691.v28b_14c465a_b_b_
workflow-durable-task-step:1247.v7f9dfea_b_4fd0
workflow-job:1308.v58d48a_763b_31
workflow-multibranch:756.v891d88f2cd46
workflow-scm-step:415.v434365564324
workflow-step-api:639.v6eca_cd8c04a_a_
workflow-support:839.v35e2736cfd5c
What Operating System are you using (both controller, and any agents involved in the problem)?
Fedora 37
Reproduction steps
- Add resource
- label: labelA
- property: PROPA = SomePropertyValue
- Run Jenkins Pipeline job with this step:
lock(label: "labelA", variable: 'LOCKED_RESOURCE', resource: null, quantity: 1) { echo "Locked resource name: $env.LOCKED_RESOURCE" echo "Locked resource product: $env.LOCKED_RESOURCE_PROPA" echo "Locked resource product: $env.LOCKED_RESOURCE0_PROPA" }
Expected Results
According to the readme, an environment variable LOCKED_RESOURCE_PROPA should exist, and an indexed/numbered variable will be used when multiple resources are locked.
Actual Results
LOCKED_RESOURCE_PROPA does not exist. LOCKED_RESOURCE0_PROPA does exist.
Anything else?
No response
OK, I see. Nice catch. But. Waht happens, when somebody use it and do not care about multiple or single resouce? Mostly programmers are lazy, therefore I think it mitght be break-change. So a note for developer. Please add break-change notice in the PR, to make correct release notes.
You can make both the normal variable and the indexed variable always available. Then I don't think there are breaking changes.
One resource is locked, the following env variables exist:
- LOCKED_RESOURCE
- LOCKED_RESOURCE_PROPA
- LOCKED_RESOURCE0 with same value as LOCKED_RESOURCE
- LOCKED_RESOURCE0_PROPA with same value as LOCKED_RESOURCE_PROPA
Multiple resources are locked:
- same variables as when one resource is locked (for the first resource)
- LOCKED_RESOURCE1
- LOCKED_RESOURCE1_PROPA
- ...
Please assign me this issue