我有类似下面这样的云构建文件
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我想要做的是,像这样定义一个变量( -now ),或者在环境变量中定义,然后把这个变量放在我的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我该怎么做呢?
发布于 2020-06-03 20:00:10
正如官方docs中所述,您可以利用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 valuehttps://stackoverflow.com/questions/62171637
复制相似问题