Gcloud 命令未在 gitlab 上运行 ci yml 警告:此处文档在文件末尾的行 ted(想要"EOF")/bin/bash:: EOF:找不到命令



当我在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```

gitlab和heredoc语法(<<-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 &"

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

最新更新