0

我正在尝试在 Jenkins 管道中启动 Datadog 代理,但出现以下错误:

第 7 行:警告:第 2 行的此处文档由文件结尾分隔(需要“EOF”)。EOF:找不到命令错误。

    stage('Install Datadog agent'){
        when {
            environment(name: "DATADOG_REQ", value: "enable")
            }
        steps {
            script {
            echo "Installing Datadog Agent"
            
            sh '''#!/bin/bash 
                ssh -o ConnectTimeout=30 -t  ABC@1234 /bin/bash  << EOF || error_exit "creating based folder failed for $service_name"
                sudo chmod u+x ./${JOB_NAME}/enableDatadogAgent.sh
                sudo chown jenkins:jenkins ./${JOB_NAME}/enableDatadogAgent.sh
                echo ${DATADOG_REQ} ${JOB_NAME}
                ./${JOB_NAME}/enableDatadogAgent.sh ${DATADOG_REQ} 
                EOF'''
                }



            }
        }

任何帮助都会非常有帮助。

4

1 回答 1

0

我用 <<- _EOF_ 更改了 << EOF,现在它可以工作了。

            script {
            echo "Installing Datadog Agent"
            
            sh '''#!/bin/bash 
                ssh -o ConnectTimeout=30 -t  ABC@1234 /bin/bash  <<- _EOF_ || error_exit "Failed to execute while doing SSH"    
                    sudo chmod u+x ./${JOB_NAME}/enableDatadogAgent.sh
                    sudo chown jenkins:jenkins ./${JOB_NAME}/enableDatadogAgent.sh
                    echo ${DATADOG_REQ} ${JOB_NAME}
                    ./${JOB_NAME}/enableDatadogAgent.sh ${DATADOG_REQ} 
                    _EOF_'''

                }
于 2022-02-07T12:07:29.507 回答