gcloud.builds.submit 在传递 env 时抛出无法识别的参数

gcloud.builds.submit throws unrecognized arguments while passing env

我快要疯了。

我正在阅读文档:https://cloud.google.com/sdk/gcloud/reference/builds/submit?hl=it#--pack 这里说使用 --pack=[builder=BUILDER],[env=ENV],[image=IMAGE]

To pass environment variables to the builder use the optional "env" key/value argument where value is a list of key values using escaping if necessary.

所以我将我从文档中理解的内容实现为,

gcloud builds submit —pack env="CONFIGURATION=production" --tag gcr.io/web-client --timeout=15000s

但它会抛出错误:

ERROR: (gcloud.builds.submit) unrecognized arguments: env=CONFIGURATION=production 

那么env变量的传递方式是什么?

为了将环境变量传递给实例,您可以使用 --substitutions flag. I had to use this as you can not combine --config, --pack and/or --tag in 1 command. (see: "At most one of these may be specified:" here) 这个很容易看过去,也是上面的问题

这让我可以传递其他环境变量。

gcloud builds submit --config ./cloudbuild.yaml --substitutions _SOME_VAR=$SOME_VAR,_SOME_OTHER_VAR='some_value'

您可以在此处找到更多信息:https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values

注意:用户定义的变量必须有_前缀。 Source