Jenkins multi-line shell with control character

I am having strange problems with a pipeline script. I have some sh blob lines like

sh """
   git tag -fa \\"${version}\\" -m \\"Release of ${version}\\"
"""

And it somehow works like:

+ git tag -fa '"1.0-16-959069f'
error: Terminal is dumb, but EDITOR unset
Please supply the message using either -m or -F option.

So he drops the -mmessage as well. I tried single screens, double screens, nothing works.

+4
source share
1 answer

I have no idea why this worked, but it did

def tagGithub(String version) {
    def exec = """
    git tag -d ${version} || true
    git push origin :refs/tags/${version}

    # tag new version
    git tag -fa ${version} -m "Release of ${version}"
    git push origin --tags
    """

    sh exec
}

Something with jenkins groovy built-in interpolation seems ruined by doing the interpolation in another var and then doing its work

+1
source

Source: https://habr.com/ru/post/1663888/


All Articles