How to set variables in a multi-line shell script within Jenkins Groovy?

后端 未结 2 1771
傲寒
傲寒 2020-12-14 05:35

Suppose I have a Groovy script in Jenkins that contains a multi-line shell script. How can I set and use a variable within that script? The normal way produces an error:

2条回答
  •  心在旅途
    2020-12-14 06:00

    I'm just putting a '\' on the end of line

    sh script: """\
      foo='bar' \
      echo $foo \
    """, returnStdout: true
    

    This statement works on my script.

提交回复
热议问题