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.
The easiest way to set environment variables in Bash is to use the “export” keyword followed by the variable name, an equal sign and the value to be assigned to the environment variable.
You can set your own variables at the command line per session, or make them permanent by placing them into the ~/. bashrc file, ~/. profile , or whichever startup file you use for your default shell. On the command line, enter your environment variable and its value as you did earlier when changing the PATH variable.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With