sh块上带有“>>”分隔符的Jenkins多行字符串

vlf7wbxs  于 2023-02-21  发布在  Jenkins
关注(0)|答案(1)|浏览(128)

我尝试给bash变量赋值一个多行字符串:

stage('test step') {
      steps {
             sh '''#!/bin/bash -xe

             read -r -d '' MULTI_LINE_VAR_STRING <<EOF
             example row 1
             example row 2
             example row 3
             EOF
             ''' 
      }
}

但Jenkins执行后,我收到一个一般性错误:

ERROR: script returned exit code 1

我需要使用读取命令,因为内容是动态的。

bfnvny8b

bfnvny8b1#

这条线必须正好是EOF,它的前面和后面都没有。

stage('test step') {
      steps {
             sh '''#!/bin/bash -xe

             read -r -d '' MULTI_LINE_VAR_STRING <<EOF
             example row 1
             example row 2
             example row 3
EOF
             ''' 
      }
}

相关问题