Jenkins and plugins versions report
Environment
Below is from a fresh Jenkins docker container with the OpenTelemetry plugin installed
docker run --restart always -d -p 8080:8080 jenkins/jenkins:lts-jdk21
Jenkins: 2.516.3
OS: Linux - 6.10.14-linuxkit
Java: 21.0.8 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
---
ant:518.v8d8dc7945eca_
antisamy-markup-formatter:173.v680e3a_b_69ff3
apache-httpcomponents-client-4-api:4.5.14-269.vfa_2321039a_83
apache-httpcomponents-client-5-api:5.5-170.v023de017ccd7
asm-api:9.8-163.vb_2a_96d3f9c3c
bootstrap5-api:5.3.8-895.v4d0d8e47fea_d
bouncycastle-api:2.30.1.82-277.v70ca_0b_877184
branch-api:2.1253.v6e7f7519f710
build-timeout:1.38
caffeine-api:3.2.2-178.v353b_8428ed56
checks-api:373.vfe7645102093
cloudbees-folder:6.1045.vb_ddd55e2d03f
commons-lang3-api:3.19.0-104.v12125f33a_255
commons-text-api:1.14.0-194.v804a_dc3a_1b_d8
credentials:1447.v4cb_b_539b_5321
credentials-binding:702.vfe613e537e88
dark-theme:574.va_19f05d54df5
display-url-api:2.217.va_6b_de84cc74b_
durable-task:605.v9a_b_9040c9970
echarts-api:6.0.0-1165.vd1283a_3e37d4
eddsa-api:0.3.0.1-19.vc432d923e5ee
email-ext:1925.v1598902b_58dd
font-awesome-api:7.0.1-872.vb_679b_2c95492
git:5.7.0
git-client:6.4.0
github:1.45.0
github-api:1.330-492.v3941a_032db_2a_
github-branch-source:1869.vdb_846d75405b_
gradle:2.16.1149.v711b_998b_0532
gson-api:2.13.2-173.va_a_092315913c
instance-identity:203.v15e81a_1b_7a_38
ionicons-api:94.vcc3065403257
jackson2-api:2.20.0-411.v6ef8fdee4fe9
jakarta-activation-api:2.1.3-2
jakarta-mail-api:2.1.3-3
javax-activation-api:1.2.0-8
jaxb:2.3.9-133.vb_ec76a_73f706
jjwt-api:0.11.5-120.v0268cf544b_89
joda-time-api:2.14.0-149.v1c3ce991d1b_9
jquery3-api:3.7.1-619.vdb_10e002501a_
json-api:20250517-173.v596efb_962a_31
json-path-api:2.9.0-190.veefca_05d5477
jsoup:1.21.2-66.v6ea_38164b_8a_2
junit:1355.v45e2ea_65863c
ldap:793.v754d6b_41b_ea_4
mailer:522.va_995fa_cfb_8b_d
matrix-auth:3.2.8
matrix-project:858.vb_b_eb_9a_7ea_99e
metrics:4.2.33-484.v2fcd689980d1
mina-sshd-api-common:2.16.0-167.va_269f38cc024
mina-sshd-api-core:2.16.0-167.va_269f38cc024
okhttp-api:4.12.0-195.vc02552c04ffd
opentelemetry:3.1543.1545.vf5a_4ec123769
opentelemetry-api:1.49.0.82.vf56234f0d9c1
pipeline-build-step:571.v08a_fffd4b_0ce
pipeline-github-lib:65.v203688e7727e
pipeline-graph-analysis:245.v88f03631a_b_21
pipeline-graph-view:646.va_da_a_047edca_c
pipeline-groovy-lib:763.v13008816b_de7
pipeline-input-step:534.v352f0a_e98918
pipeline-milestone-step:138.v78ca_76831a_43
pipeline-model-api:2.2273.v643f36ed9e94
pipeline-model-definition:2.2273.v643f36ed9e94
pipeline-model-extensions:2.2273.v643f36ed9e94
pipeline-stage-step:322.vecffa_99f371c
pipeline-stage-tags-metadata:2.2273.v643f36ed9e94
plain-credentials:199.v9f8e1f741799
plugin-util-api:6.1192.v30fe6e2837ff
resource-disposer:0.25
scm-api:709.v6c27075a_b_1c7
script-security:1378.vf25626395f49
snakeyaml-api:2.3-125.v4d77857a_b_402
ssh-credentials:361.vb_f6760818e8c
ssh-slaves:3.1071.v0d059c7b_c555
structs:353.v261ea_40a_80fb_
theme-manager:319.v9193461f9671
timestamper:1.30
token-macro:477.vd4f0dc3cb_cf1
trilead-api:2.209.v0e69b_c43c245
variant:70.va_d9f17f859e0
workflow-aggregator:608.v67378e9d3db_1
workflow-api:1384.vdc05a_48f535f
workflow-basic-steps:1098.v808b_fd7f8cf4
workflow-cps:4209.v83c4e257f1e9
workflow-durable-task-step:1464.v2d3f5c68f84c
workflow-job:1549.vc8d7f497b_22f
workflow-multibranch:821.vc3b_4ea_780798
workflow-scm-step:452.vdf1ca_c8d3a_87
workflow-step-api:710.v3e456cc85233
workflow-support:989.va_20a_1a_57710a_
ws-cleanup:0.49
What Operating System are you using (both controller, and any agents involved in the problem)?
The above environment output is from a docker container running on MacOS 15.6.1, however, I have seen the same result on in a CloudBees enterprise container running within a kubernetes cluster.
Reproduction steps
Optional Setup
If you want, you can run a new Jenkins instance locally using docker
Step 1: Run Jenkins as a docker image locally
docker run --restart always -d -p 8080:8080 jenkins/jenkins:lts-jdk21
Step 2: Install the OpenTelemtry Plugin and it's dependencies
Reproducing the issue
Below are two Jenkinsfiles, one scripted and one declarative that outline this issue. With their respective raw output.
The main observations here are:
env.TRACEPARENT is the same on both stages
- the span id component of the
env.TRACEPARENT maps to Phase: Run
Scripted Pipeline
node('') {
stage("Stage 1"){
sh 'echo TRACEPARENT from shell: ${TRACEPARENT}'
echo "TRACEPARENT from env: ${env.TRACEPARENT}"
}
stage("Stage 2"){
sh 'echo TRACEPARENT from shell: ${TRACEPARENT}'
echo "TRACEPARENT from env: ${env.TRACEPARENT}"
}
}
Started by user admin
Replayed #2
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/trace-parent-test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Stage 1)
[Pipeline] sh
+ echo TRACEPARENT from shell: 00-37aa43338df07b193ed5de903d015eff-1c9e31366bf2fcdf-01
TRACEPARENT from shell: 00-37aa43338df07b193ed5de903d015eff-1c9e31366bf2fcdf-01
[Pipeline] echo
TRACEPARENT from env: 00-37aa43338df07b193ed5de903d015eff-c47e9a2311af8778-01
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Stage 2)
[Pipeline] sh
+ echo TRACEPARENT from shell: 00-37aa43338df07b193ed5de903d015eff-a03d15a3ae302d63-01
TRACEPARENT from shell: 00-37aa43338df07b193ed5de903d015eff-a03d15a3ae302d63-01
[Pipeline] echo
TRACEPARENT from env: 00-37aa43338df07b193ed5de903d015eff-c47e9a2311af8778-01
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Declarative Pipeline
pipeline{
agent any
stages{
stage("Stage 1"){
steps{
sh 'echo TRACEPARENT from shell: ${TRACEPARENT}'
echo "TRACEPARENT from env: ${env.TRACEPARENT}"
}
}
stage("Stage 2"){
steps{
sh 'echo TRACEPARENT from shell: ${TRACEPARENT}'
echo "TRACEPARENT from env: ${env.TRACEPARENT}"
}
}
}
}
Started by user admin
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/trace-parent-test
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Stage 1)
[Pipeline] sh
+ echo TRACEPARENT from shell: 00-d49296d34d64cf5b18319d6ca99de595-9c322c6d9a6d0b3d-01
TRACEPARENT from shell: 00-d49296d34d64cf5b18319d6ca99de595-9c322c6d9a6d0b3d-01
[Pipeline] echo
TRACEPARENT from env: 00-d49296d34d64cf5b18319d6ca99de595-c536e63c76c4767d-01
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Stage 2)
[Pipeline] sh
+ echo TRACEPARENT from shell: 00-d49296d34d64cf5b18319d6ca99de595-7abc36836a7ad5f5-01
TRACEPARENT from shell: 00-d49296d34d64cf5b18319d6ca99de595-7abc36836a7ad5f5-01
[Pipeline] echo
TRACEPARENT from env: 00-d49296d34d64cf5b18319d6ca99de595-c536e63c76c4767d-01
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS
Expected Results
sh echo ${TRACEPARENT} and echo env.TRACEPARENT should produce the same value
echo env.TRACEPARENT should produce different values between stages
Actual Results
sh echo ${TRACEPARENT} and echo env.TRACEPARENT produce different values
echo env.TRACEPARENT produces the same value between pipeline stages
echo env.TRACEPARENT maps to the Phase: Run span
Anything else?
Obviously, the intended purpose of these environment variables are to be used in an agent contexts where build tools access these variables directly, however, in the case of shared libraries where we have no guarantee of the underlying agent runtime, i.e. windows vs *nix agents. extra handling needs to be added in order for these variables to be picked up appropriately.
Are you interested in contributing a fix?
No response
Jenkins and plugins versions report
Environment
Below is from a fresh Jenkins docker container with the OpenTelemetry plugin installedWhat Operating System are you using (both controller, and any agents involved in the problem)?
The above environment output is from a docker container running on MacOS 15.6.1, however, I have seen the same result on in a CloudBees enterprise container running within a kubernetes cluster.
Reproduction steps
Optional Setup
If you want, you can run a new Jenkins instance locally using docker
Step 1: Run Jenkins as a docker image locally
Step 2: Install the OpenTelemtry Plugin and it's dependencies
Reproducing the issue
Below are two Jenkinsfiles, one scripted and one declarative that outline this issue. With their respective raw output.
The main observations here are:
env.TRACEPARENTis the same on both stagesenv.TRACEPARENTmaps toPhase: RunScripted Pipeline
Declarative Pipeline
pipeline{ agent any stages{ stage("Stage 1"){ steps{ sh 'echo TRACEPARENT from shell: ${TRACEPARENT}' echo "TRACEPARENT from env: ${env.TRACEPARENT}" } } stage("Stage 2"){ steps{ sh 'echo TRACEPARENT from shell: ${TRACEPARENT}' echo "TRACEPARENT from env: ${env.TRACEPARENT}" } } } }Expected Results
sh echo ${TRACEPARENT}andecho env.TRACEPARENTshould produce the same valueecho env.TRACEPARENTshould produce different values between stagesActual Results
sh echo ${TRACEPARENT}andecho env.TRACEPARENTproduce different valuesecho env.TRACEPARENTproduces the same value between pipeline stagesecho env.TRACEPARENTmaps to thePhase: RunspanAnything else?
Obviously, the intended purpose of these environment variables are to be used in an agent contexts where build tools access these variables directly, however, in the case of shared libraries where we have no guarantee of the underlying agent runtime, i.e. windows vs *nix agents. extra handling needs to be added in order for these variables to be picked up appropriately.
Are you interested in contributing a fix?
No response