12

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.

2
  • Does the string replacement just not work, or do you get an error message, or does the 3.0 in the version get replaced with nothing ? Commented Jan 10, 2014 at 0:31
  • Similar question stackoverflow.com/a/41659007/984471 Commented Feb 21, 2018 at 15:57

1 Answer 1

16

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.