steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud container images list-tags gcr.io/blah/app | grep prod | head -n 1 | awk '{print \$2}' | cut -d ',' -f 2 | awk -F. '{\$NF = \$NF + 1;} 1' | sed 's/ /./g' > version.txt
我在本地用docker和cloudbuild镜像运行了这个程序。
bash -c "gcloud container images list-tags gcr.io/blah/app | grep prod | head -n 1 | awk '{print \$2}' | cut -d ',' -f 2 | awk -F. '{\$NF = \$NF + 1;} 1' | sed 's/ /./g' > version.txt"
而且它是有效的。但是当我把它发送到cloudbuild时,我得到了
awk: 1: unexpected character '\'
awk: 1: unexpected character '\'
awk: line 1: syntax error at or near =
发布于 2020-09-22 17:45:09
仅仅使用$$是不够的。您还需要删除/。这是对我有效的方法:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud container images list-tags gcr.io/blah/app | grep prod | head -n 1 | awk '{print $$2}' | cut -d ',' -f 2 | awk -F. '{$$NF = $$NF + 1;} 1' | sed 's/ /./g' > version.txt
https://stackoverflow.com/questions/63984458
复制相似问题