1

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?

kuzua
  • 177
  • 2
  • 9
  • 1
    It seems like the syntax should instead be this, unless you've already tried this: `--pack=env=CONFIGURATION=production`. It looks like you have an em dash (`—` vs `--`) in your command unless that was a typo when making this post. – cam Mar 23 '21 at 21:52
  • The instructions say 'The "image" key/value must be provided'. So you need to use `--pack=env=CONFIGURATION=production,image=${SOMETHING}` and should not include `--tag=`. – DazWilkin Mar 24 '21 at 03:04

1 Answers1

1

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

Ralph Bisschops
  • 1,888
  • 1
  • 22
  • 34