如何在cloudbuild.yaml文件中设置环境变量?

How to set the environment variable in cloudbuild.yaml file?

我正在尝试设置 GOOGLE_APPLICATION_CREDENTIALS。这是设置环境变量的正确方法吗?下面是我的 yaml 文件:

steps:
- name: 'node:10.10.0'
  id: installing_npm
  args: ['npm', 'install']
  dir: 'API/system_performance'
- name: 'node:10.10.0'
  #entrypoint: bash
  args: ['bash', 'set GOOGLE_APPLICATION_CREDENTIALS=test/emc-ema-cp-d-267406-a2af305d16e2.json']
  id: run_test_coverage
  args: ['npm', 'run', 'coverage']
  dir: 'API/system_performance'

请帮我解决这个问题。

您可以使用 env step parameter

但是,当您执行 Cloud Build 时,the platform uses its own service account(将来可以指定您要使用的服务帐户)

因此,如果您向 Cloud Build 服务帐户授予正确的角色,则无需使用密钥文件(该文件在您的 Git 存储库中提交,这不是一个很好的做法!)