Google cloud platform 使用环境变量的Cloudbuild.yaml?

Google cloud platform 使用环境变量的Cloudbuild.yaml?,google-cloud-platform,yaml,google-cloud-build,Google Cloud Platform,Yaml,Google Cloud Build,我有这样的云构建文件 steps: - name: 'python:3.7' entrypoint: 'bash' args: - '-c' - | pip3 install -r requirements.txt pytest -rP #- name: 'gcr.io/cloud-builders/gcloud' # args: # - functions # - deploy # - Test_Function # -

我有这样的云构建文件

steps:

- name: 'python:3.7'
  entrypoint: 'bash'
  args: 
    - '-c'
    - |
        pip3 install -r requirements.txt
        pytest -rP

#- name: 'gcr.io/cloud-builders/gcloud'
#  args:
#  - functions
#  - deploy
#  - Test_Function
#  - --runtime=python37
#  - --source=https://source.developers.google.com/projects/proj_name/repos/repo_name/moveable-aliases/master/paths/function
#  - --entry-point=main
#  - --trigger-topic=Test_Topic
#  - --region=region
-现在我想做的是,我想定义soemthing,比如一个变量(Test_name)或环境变量,并将该变量放在yaml的不同行中,如下所示

Test_name: "my_name"
steps:

- name: 'python:3.7'
  entrypoint: 'bash'
  args: 
    - '-c'
    - |
        pip3 install -r requirements.txt
        pytest -rP

#- name: 'gcr.io/cloud-builders/gcloud'
#  args:
#  - functions
#  - deploy
#  - **{Test_name}**_Function
#  - --runtime=python37
#  - --source=https://source.developers.google.com/projects/proj_name/repos/repo_name/moveable-aliases/master/paths/function
#  - --entry-point=main
#  - --trigger-topic=**{Test_name}**_Topic
#  - --region=region

我怎样才能做到这一点呢?

正如官方声明中所述,您可以利用Cloud Build的替代来实现这一点

根据上述文档中提供的示例,您的
cloudbuild.yaml
将如下所示:

Test_name: "my_name"
steps:

- name: 'python:3.7'
  entrypoint: 'bash'
  args: 
    - '-c'
    - |
        pip3 install -r requirements.txt
        pytest -rP

#- name: 'gcr.io/cloud-builders/gcloud'
#  args:
#  - functions
#  - deploy
#  - ${_TEST_NAME}_Function
#  - --runtime=python37
#  - --source=https://source.developers.google.com/projects/proj_name/repos/repo_name/moveable-aliases/master/paths/function
#  - --entry-point=main
#  - --trigger-topic=${_TEST_NAME}_Topic
#  - --region=region

substitutions:
    TEST_NAME: TEST # default value

我也尝试过,但给了我这个错误…错误:(gcloud.functions.deploy)参数--触发器主题:无效值“$(\u TEST\u NAME)\u topic”:主题只能包含拉丁字母(小写或大写)、数字和字符-+。\u~%。它必须以字母开头,长度从3到255个字符。您是否使用了大括号
{}
而不是普通括号
()
?还有,您的env变量的值是多少?没问题,很高兴能有所帮助!