I am using Jenkins Pipeline using Groovy sandbox. And i am trying to run a shell script in a groovy sh function.
The original shell script is
sed -i 's/sometext/'"${othertext}"'/' filename
I am trying to replace a particular text with other text (taken dynamically). The script works fine when executed directly. But I want to use it in jenkins groovy sh function.
sh(script: '<above shell script>', returnStdout:false)
But there is a problem of escaping characters. I tried this way of escaping character
sh (script: '''sed -i 's/sometext/othertext/' filename''', returnStdout:false)
It works fine but othertext
is not taken dynamically.
Can someone please help me in escaping characters with the original script?
Or please suggest any other way of doing this.