簡體   English   中英

Cloudbuild.yaml 與環境變量?

[英]Cloudbuild.yaml with enviroment variables?

我有這樣的雲構建文件

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

-現在我想做的是我想定義一個變量(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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM