问题
just for example. I have this part of code in groovy-pipeline:
echo "${GIT_BRANCH}"
if ("${GIT_BRANCH}" == 'origin/mysuperbranch') {
echo 'Branch name is "${GIT_BRANCH}". We can continue'
} else {
echo 'Branch name is "${GIT_BRANCH}". We can not continue'
isValid = false
return true
}
And let's look on output:
[Pipeline] echo
origin/mysuperbranch
[Pipeline] echo
Branch name is "${GIT_BRANCH}". We can continue
Why in first output i can see what is in the variable ${GIT_BRANCH}
, but in the next output, i see only ${GIT_BRANCH}
. Can you help me please ?
回答1:
Refering to the String Interpolation you are writing the variable as string to the console. You have to remove the "
from the variable and use them on the whole command to recognize variables.
echo "Branch name is ${GIT_BRANCH}. We can not continue"
来源:https://stackoverflow.com/questions/57319873/jenkins-does-not-show-variables-output-in-echo-request-in-the-groovy-pipeline