oderfla oderfla - 14 days ago 5
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

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

Comments