I have some issue to escape quote character in my jenkins pipeline. for example :
I want to append a text in to file through the pipeline using this command below:
openshift.rsh("${podname}", """sh -c 'echo "define( 'WP_HOME', 'http://rabah-test.com' );" >> wp-config.php'""")
and expecting this in to the wp-config.php file:
define( 'WP_HOME', 'http://rabah-test.com' );
but unfortunately i don't have the quotes in my result :
define( WP_HOME, http://rabah-test.com );
I believe it is not an issue with jenkins. Try to run your command in the terminal first. You have a simple quotes for your sh command and simple quotes inside the define.
I would try something like
sh -c 'echo "define( \'WP_HOME\', \'http://rabah-test.com\' );" >> wp-config.php'
Note, instead of adding the define to the wp-config.php file, I would be tempted to version a default WP_HOME and replace it by a sed
I found how to deal with it. Instead of using simple quotes, I decided to use double quotes and escape with two backslashes.
Like this:
sh -c 'echo "define( \\" WP_HOME \\" , \\" http://rabah-test.com \\" );" >> wp-config.php'
And it now works perfectly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.