| Hi, I have a declarative pipeline, where the pod contains a few containers, during the execution I want to specify where to run a particular step, so I use the container() step. When I declare an environment variable that contains '$' as value and try to use it in the container step the '$' is doubled. I originally noticed this with the credential-binding plugin, but I figured that it can be reproduced with simply using environment variables. I've created a simple pipeline to demonstrate:
pipeline {
agent any
environment {
FRUIT = '$apple'
}
stages {
stage("Test") {
steps{
sh 'echo "${FRUIT}"'
container('jnlp') {
sh 'echo "${FRUIT}"'
}
}
}
}
}
Result:
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] sh
+ echo $apple
$apple
[Pipeline] container
[Pipeline] {
[Pipeline] sh
+ echo $$apple
$$apple
|