In jenkins pipeline I'm defining a condition for where clause in sql statement:
else if (params.targetEnv == "dev"){
condition = "where DATABASENAME like '%dev%'"}
Then I want to replace the condition placeholder in sql file:
sh """sed -i 's/@condition@/${condition}/' ${sql_query_file}"""
But in the file I get where DATABASENAME like %dev%
instead where DATABASENAME like '%dev%'
that means without the single quotes.
Does anybody know how can I pass there the condition with the single quotes?
sh "sed -i \"s/@condition@/${condition}/\" ${sql_query_file}"
def condition = "foo"
echo "$condition"
println "$condition"
sed -i 's/SEARCH_REGEX/REPLACEMENT/g' INPUTFILE
sed -i "s/SEARCH_REGEX/REPLACEMENT/g" INPUTFILE
Double quote should be used if some var is used in the sed argument
echo " foo is \"bar\" "
sh "sed -i \"s/@condition@/${condition}/\" ${sql_query_file}"