【问题标题】:Gcloud command not running on gitlab ci yml warning: here-document at line ted by end-of-file (wanted `EOF') /bin/bash: : EOF: command not foundGcloud 命令未在 gitlab ci yml 警告上运行:here-document at line ted by end-of-file (wanted `EOF') /bin/bash: : EOF: command not found
【发布时间】:2021-01-21 12:57:02
【问题描述】:

当我在 gitlab-ci.yml 中运行以下 gcloud 命令时出现以下错误

/bin/bash: line 152: warning: here-document at line 152 delimited by end-of-file (wanted `EOF') /bin/bash: line 152: EOF: command not found

- gcloud compute ssh --zone asia-southeast1-b instance-1 --command="bash -s" <<-EOF
     fuser -k 8080/tcp
     nohup java -jar /home/XXX/XXX-1.0-SNAPSHOT.jar > /dev/null 2>&1 &
     EOF```

【问题讨论】:

    标签: bash docker gitlab-ci gcloud


    【解决方案1】:

    gitlab 和 heredoc 语法 (&lt;&lt;-EOF) 都有特定的空白要求,它们会发生冲突。

    幸运的是,只要保持缩进,yaml 就允许使用多行命令,因此不需要使用heredoc 表示法。这可以按如下方式完成:

      - gcloud compute ssh --zone asia-southeast1-b instance-1 --command="bash -s
        fuser -k 8080/tcp;
        nohup java -jar /home/XXX/XXX-1.0-SNAPSHOT.jar > /dev/null 2>&1 &"
    

    请注意,命令之间还引入了分号。

    【讨论】:

    • 它的工作原理是 GitLab 不会出错。但是当我尝试使用 export varA=val 设置环境变量以在远程服务器中设置它时。它并没有真正设置这些变量。知道为什么这不起作用吗?
    猜你喜欢
    • 2022-12-10
    • 2017-01-29
    • 2021-04-06
    • 2012-09-12
    • 2021-01-28
    • 1970-01-01
    • 2013-02-17
    • 2021-02-23
    • 1970-01-01
    相关资源
    最近更新 更多