One way to display a variable in a Jenkins script that contains single quotes without causing an error is to use double quotes instead of single quotes. For example:
echo "The value of my variable is $myVariable"
Alternatively, you can escape the single quotes with a backslash.
echo 'The value of my variable is '\''$myVariable'\'''
This tells the shell to treat the single quotes around $myVariable as literal characters.
Asked: 2022-01-28 11:00:00 +0000
Seen: 13 times
Last updated: Feb 08 '22