Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace string in jenkins pipeline using groovy script

I'm trying to replace a string in jenkins pipeline using groovy script the string is

input : prakash/annam/devops
expected output : prakash/\annam/\devops

I'm using this sed -i 's#/#/\#g' . Unfortunately it is working in shell scripting but not in jenkins pipeline. Please give me a solution.

like image 448
Saiprakash annam.a Avatar asked Nov 18 '25 05:11

Saiprakash annam.a


1 Answers

'prakash/annam/devops'.replaceAll("/", "/\\\\")

will do what you want. Refer here: https://stackoverflow.com/a/6377310/3355860

like image 121
ou_ryperd Avatar answered Nov 20 '25 20:11

ou_ryperd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!