Hello I am facing this issue when I try to replace string using SED in Groovy, it's ignoring the Single quotes which I am passing. Here is my code I tried using double quotes inside sed and it's throwing errors.
stage('Version')
{
dir('./Dest/Scripts/')
{
sh "sed -i 's/VERSION_BUILD=0/VERSION_BUILD= '$Version', System2 = '$name'/g' setversion.sql"
}
}
My desired output is
UPDATE &Shared_Version SET SharedVersion = '2010', System1 = 'XXXX', InetsoftVersion = 2, VERSION_BUILD='20180302', System2 = 'test';
COMMIT;
however I am getting below results after I run the Groovy script.
UPDATE &Shared_Version SET SharedVersion = '2010', System1 = 'XXXX', InetsoftVersion = 2, VERSION_BUILD= 20180302, System2 = test;
COMMIT;
I do know in shell Command if we pass double quotes it will replace, however Groovy is not liking it.
sed -i "s/VERSION_BUILD=0/VERSION_BUILD= '$Version', System2 = '$name'/g" setversion.sql
Can some one help me to address this problem here.
Thanks
sh $/sed -i "s/VERSION_BUILD=0/VERSION_BUILD= '$Version', System2 = '$name'/g" setversion.sql/$- tim_yatesgroovy.lang.MissingPropertyException: No such property: $ for class: groovy.lang.Binding at groovy.lang.Binding.getVariable(Binding.java:63) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)- saint