当我在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```发布于 2021-01-21 22:43:01
gitlab和heredoc语法(<<-EOF)都有冲突的特定空格要求。
幸运的是,只要保持缩进,yaml就允许使用多行命令,因此这里不需要使用not符号。这可以按如下方式完成:
- 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 &"请注意,命令之间也引入了分号。
https://stackoverflow.com/questions/65827935
复制相似问题