Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.secrets.secretEnv does not work with "_" (underscores) in variable name #413

Closed
nieldw opened this issue Dec 4, 2018 · 1 comment
Closed

Comments

@nieldw
Copy link

nieldw commented Dec 4, 2018

Using underscores in secret environment variables fail

Using an "_" (underscore) in a secret environment variable in a cloudbuild.yaml fails with this misleading message:

ERROR: (gcloud.builds.submit) INVALID_ARGUMENT: invalid build: invalid .secrets field: secretEnv "DOCKER_PASSWORD" is used without being defined

The cloudbuild.yaml that produced this is:

steps:
  - name: 'gcr.io/cloud-builders/docker'
    entrypoint: /bin/bash
    args: ['-c', 'docker login --username cloudbuildexample --password $$DOCKER_PASSWORD']
    secretEnv: ['DOCKER_PASSWORD']
secrets:
  - kmsKeyName: 'projects/secretenvexample/locations/global/keyRings/dockercredentials/cryptoKeys/cloudbuildexample'
    secretEnv:
      DOCKER_PASSWORD: CiQAv9iGjQ6oIU7SaPZeXpQmb97SjKsaVCAr46d2SfBGO/bqencSMQAWjKvDvLVCTrVG9KusWfneyIGZtIw9Fobk2KZIPQU8LKVHUIMltaZf3vWBluPS/PI=

It is possible to use underscores, although it's unintuitive

A variable with an underscore, like DOCKER_PASSWORD, can be referenced by changing the part after the underscore to sentence case, like DOCKERPassword.

Here is a working example of a cloudbuild.yaml demonstrating this behaviour:

steps:
  - name: 'gcr.io/cloud-builders/docker'
    entrypoint: /bin/bash
    args: ['-c', 'docker login --username cloudbuildexample --password $$DOCKERPassword']
    secretEnv: ['DOCKERPassword']
secrets:
  - kmsKeyName: 'projects/secretenvexample/locations/global/keyRings/dockercredentials/cryptoKeys/cloudbuildexample'
    secretEnv:
      DOCKER_PASSWORD: CiQAv9iGjQ6oIU7SaPZeXpQmb97SjKsaVCAr46d2SfBGO/bqencSMQAWjKvDvLVCTrVG9KusWfneyIGZtIw9Fobk2KZIPQU8LKVHUIMltaZf3vWBluPS/PI=

$ gcloud --version
Google Cloud SDK 224.0.0
bq 2.0.36
core 2018.11.02
gsutil 4.34
@nieldw
Copy link
Author

nieldw commented Dec 5, 2018

It seems that the issue has been fixed already with the new version of gcloud:

$ gcloud --version
Google Cloud SDK 226.0.0
bq 2.0.38
core 2018.11.16
gsutil 4.34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant