How to use Jenkins environment variable in shell script?

bash, jenkins

Solution

As shellcheck would tell you, expansions don't happen in single quotes. Use double quotes instead:

sed -i "s/Version 3.0/Version $BUILD_DISPLAY_NAME/g" /var/lib/jenkins/jobs/AndroidTest/workspace/xxx/res/values/strings.xml

Problem

I want to update a java file with the jenkins build number. I plan on using a shell script to sed the value to the correct build number. I'm currently doing this: ``` sed -i 's/Version 3.0/Version $BUILD_DISPLAY_NAME/g' /var/lib/jenkins/jobs/AndroidTest/workspace/xxx/res/values/strings.xml ``` Why doesn't this work? I'd assume I could just use them directly.

Original source

Related problems