GCloud 构建 YAML 替换不起作用
GCloud build YAML substitutions don't work
我有一个构建配置文件,如下所示:
steps:
...
<i use the ${_IMAGE} variable around 4 times here>
...
images: ['${_IMAGE}']
options:
dynamic_substitutions: true
substitutions:
_IMAGE: http://example.com/image-${_ENVIRON}
然后我像这样触发构建:
gcloud builds submit . --config=config.yaml --substitutions=_ENVIRON=prod
我期望 gcloud 替换脚本中的 _ENVIRON 变量,然后替换 _IMAGE 变量,以便它扩展为 'http://example.com/image-prod' - 但我收到以下错误:
ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: generic::invalid_argument: key "_ENVIRON" in the substitution data is not matched in the template
我该怎么做才能让它发挥作用?我真的希望能够使用 sub 轻松更改环境,而无需更改代码中的任何内容
如您所见,这是不可能的。
如果 _ENVIRON
的唯一用途是 _IMAGE
,为什么不从 config.yaml
中删除 substitions
并使用 _IMAGE
作为替代:
ENVIRON="prod"
IMAGE: http://example.com/image-${ENVIRON}
gcloud builds submit . \
--config=config.yaml \
--substitutions=_IMAGE=${IMAGE}
我有一个构建配置文件,如下所示:
steps:
...
<i use the ${_IMAGE} variable around 4 times here>
...
images: ['${_IMAGE}']
options:
dynamic_substitutions: true
substitutions:
_IMAGE: http://example.com/image-${_ENVIRON}
然后我像这样触发构建:
gcloud builds submit . --config=config.yaml --substitutions=_ENVIRON=prod
我期望 gcloud 替换脚本中的 _ENVIRON 变量,然后替换 _IMAGE 变量,以便它扩展为 'http://example.com/image-prod' - 但我收到以下错误:
ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: generic::invalid_argument: key "_ENVIRON" in the substitution data is not matched in the template
我该怎么做才能让它发挥作用?我真的希望能够使用 sub 轻松更改环境,而无需更改代码中的任何内容
如您所见,这是不可能的。
如果 _ENVIRON
的唯一用途是 _IMAGE
,为什么不从 config.yaml
中删除 substitions
并使用 _IMAGE
作为替代:
ENVIRON="prod"
IMAGE: http://example.com/image-${ENVIRON}
gcloud builds submit . \
--config=config.yaml \
--substitutions=_IMAGE=${IMAGE}