Ask Your Question
4

How can a variable be displayed in a Jenkins script if the script contains single quotes without causing an error?

asked 2022-01-28 11:00:00 +0000

bukephalos gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-02-08 09:00:00 +0000

plato gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-28 11:00:00 +0000

Seen: 12 times

Last updated: Feb 08 '22