gcloud builds submit substitutions not working properly. (ERROR: (gcloud.builds.submit) INVALID_ARGUMENT.)

gcloud builds submit substitutions not working properly. (ERROR: (gcloud.builds.submit) INVALID_ARGUMENT.)

我有以下配置:

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

它 运行s 但替换仅采用第一个变量,其他变量成为它的值:

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: branch T: tag C => client

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