gcpug / nouhau

Google Cloud Platformのノウハウを共有するRepository
https://gcpug.jp
MIT License
653 stars 23 forks source link

gcr.io/cloud-builders/curl で secretEnvを利用する 記事を追加 #63

Closed sinmetal closed 4 years ago

sinmetal commented 6 years ago

予想外にハマったので、泣きながら書いた。

apstndb commented 6 years ago

https://cloud.google.com/cloud-build/docs/securing-builds/use-encrypted-secrets-credentials?hl=en#example_build_request_using_an_encrypted_variable

secretEnv をコマンドラインパラメータとして使おうとしたら必要になるため GCR 以外を使いたくて docker login する場合についてはドキュメントにも書かれていた。

# Login to provide credentials for the push.
# PASSWORD is decrypted before this step runs.
# Note: You need a shell to resolve environment variables with $$
- name: 'gcr.io/cloud-builders/docker'
  entrypoint: 'bash'
  args: ['-c', 'docker login --username=[MY-USER] --password=$$PASSWORD']
  secretEnv: ['PASSWORD']
sinmetal commented 6 years ago

そこのコメントに書いてあるのか・・・!