首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有环境变量的Cloudbuild.yaml?

带有环境变量的Cloudbuild.yaml?
EN

Stack Overflow用户
提问于 2020-06-03 19:23:32
回答 1查看 241关注 0票数 0

我有类似下面这样的云构建文件

代码语言:javascript
复制
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中的不同行,如下所示。

代码语言:javascript
复制
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

我该怎么做呢?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-03 20:00:10

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

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

代码语言:javascript
复制
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
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62171637

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档