Reputation: 217
I'm about to lose my mind.
I'm reading the doc: https://cloud.google.com/sdk/gcloud/reference/builds/submit?hl=it#--pack
And here it says that use --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.
So I implement what I understand from the documentation as,
gcloud builds submit —pack env="CONFIGURATION=production" --tag gcr.io/web-client --timeout=15000s
But it throws error as:
ERROR: (gcloud.builds.submit) unrecognized arguments: env=CONFIGURATION=production
So what is the way to pass env variable?
Upvotes: 1
Views: 2487
Reputation: 2518
In order to pass environment variables to the instance you can use the --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)
This is easy to glance over and is also a problem above.
This allowed me to pass-though other environment variables.
gcloud builds submit --config ./cloudbuild.yaml --substitutions _SOME_VAR=$SOME_VAR,_SOME_OTHER_VAR='some_value'
You can find more info here: https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
Note: user-defined variables have to have the _
prefix. Source
Upvotes: 1