无法在Jenkins groovy管道中创建文件(CAT EOF)

p3rjfoxz  于 2022-10-06  发布在  Jenkins
关注(0)|答案(1)|浏览(231)

我想创建Jenkins Groovy管道(RHEL Slave)中的内容文件。

现在我使用以下命令

steps {
                script {
                    sh """
                            cat <<EOF >>file.sh
                             echo 'Hello world'
                            EOF
                    """
                }    
            }
        }

但我是在运行Jenkins作业时收到这条消息的。

2022-09-27 21:21:06  /apps/jenkins/workspace/xxxx/xxxxxx@tmp/durable-aa115c9c/script.sh: line 7: warning: here-document at line 2 delimited by end-of-file (wanted `EOF')
2022-09-27 21:21:06  + cat

我已经检查了EOF的空间,但仍然没有工作。

请帮忙提个建议。

zpjtge22

zpjtge221#

做下面这样的事情不是很容易吗?只需将STDOUT重定向到一个文件。

sh """
     echo 'Hello world' >> file.sh
     echo 'Hello Something' >> file.sh
"""

相关问题