-
Type:
Bug
-
Resolution: Duplicate
-
Priority:
Major
-
Component/s: kubernetes-plugin
-
None
Description:
When using the kubernetes plugin and executing a script inside of a container block, environment variables that contain a literal dollar in their value appear to have an extra dollar added before the existing literal dollar.
E.g. if the environment and container block were:
environment {
FOO="\$BAH"
}
steps {
container('busybox') {
sh 'echo "FOO=$FOO"'
}
}
then the console output shows:
[Pipeline] withEnv
[Pipeline] {
[Pipeline] container
[Pipeline] {
[Pipeline] sh
+ echo 'FOO=$$BAH'
FOO=$$BAH
[Pipeline] }
[Pipeline] // container
[Pipeline] }
[Pipeline] // withEnv
Expected behaviour:
the value of the environment variable is not altered when referenced inside the container block.
Work around:
None that I've found yet.
Other info:
Some other permutations I've tried:
- When the script is executed outside of the container block, the environment variable value is unchanged.
- When the value of the environment variable contains a literal dollar not at the start of the string, the value is still changed. E.g. A value of "Something \$BAH" echoes as "Something $$BAH"
Environment where the bug was seen:
Jenkins: CloudBees Core Managed Master 2.204.3.2-rolling
Kubernetes plugin: 1.23.1
- duplicates
-
JENKINS-61950 Environment variables with '$' have '$$' when used in sh step inside a container step.
-
- Resolved
-