gcloud构建提交替换无法正常工作.(错误:(gcloud.builds.submit)INVALID_ARGUMEN



我有以下配置:

steps:
- name: 'alpine'
args: ['echo', 'B: ${_BRANCH}', 'T: ${_TAG}', 'C => ${_CLIENT}']

如果我使用运行

gcloud builds submit --config=gcp/cloudbuild-main.yaml --substitutions _CLIENT='client',_BRANCH='branch',_TAG='tag' .

我收到以下消息:

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: generic::invalid_argument: key in the template "_BRANCH" is not matched in the substitution data; substitutions = map[_CLIENT:client _BRANCH=branch _TAG=tag];key in the template "_TAG" is not matched in the substitution data; substitutions = map[_CLIENT:client _BRANCH=branch _TAG=tag];key "_CLIENT" in the substitution data is not matched in the template

如果我声明替换:

steps:
- name: 'alpine'
args: ['echo', 'B: ${_BRANCH}', 'T: ${_TAG}', 'C => ${_CLIENT}']
substitutions:
_BRANCH: b1
_TAG: latest
_CLIENT: c

它运行,但替换只接受第一个变量,其他变量变成它的值:

BUILD
Pulling image: alpine
Using default tag: latest
latest: Pulling from library/alpine
Digest: sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300
Status: Downloaded newer image for alpine:latest
docker.io/library/alpine:latest
B: b1 T: latest C => client _BRANCH=branch _TAG=tag
PUSH
DONE

您的命令中有一个语法错误,应该通过以下方法解决:

gcloud builds submit --config=gcp/cloudbuild-main.yaml --substitutions=_CLIENT="client",_BRANCH="branch",_TAG="tag" .

提交构建后:

B:分支T:标记C=>客户端

参考:https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values

相关内容

  • 没有找到相关文章

最新更新