I have a Jenkins job with an execute shell box. In the execute shell I use bash instead of dash (sh). In the execute shell I have strings which are supposed to be interpreted as they contain escape sequences (in this case the new line: \n
), so here is an example execute shell:
#!/bin/bash
set -x #echo on
git fetch
...
git commit -m "Merging $DEVELOPEMENTBRANCH into $INITIALBRANCH\n\nThis is an example second paragraph."
...
My problem here is that the script block is interpreted/replaced by Jenkins in a way that it changes its behavior, to be specific it replaces the variables and replaces the double quotes with single quotes so in the console output it looks like this:
[4] $ /bin/bash /tmp/hudson7542128982632971668.sh
+ git fetch
...
+ git commit -m 'Merging my_feature into develop\n\nThis is an example second paragraph'
...
But in this way the \n
part won't be interpreted because of the single quotes. What is the trick here? I want to preserve the double quotes or at least interpret the \n
sequences.
git commit -m "A multi-line\n\ncommit message"
will not produce a multi-line commit message anyway. The commit message will be, literally,A multi-line\n\ncommit message
. Double-quotes do not causebash
to interpretprintf
escape-sequences.To get a multi-line commit-message you need:
This works fine in a Jenkins shell step.