oderfla oderfla - 1 year ago 106
Bash Question

String parameter not working in jenkins shell

I create a new build with a parametrized string. The name fo the parameter is VERSION.

In the build I have this command:

sed -i -e 's/REPLACE_ME/$VERSION/g' config/config.json

The json file looks this way:

"ENV": {
"name": "test",
"version": "REPLACE_ME",

What happens is that REPLACE_ME is replaced by $VERSION.
I also tried with ${VERSION} but still no luck.
What am I doing wrong?

Answer Source

Surround your sed string with double quotes so that the variable is expanded properly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download