I have cloud build file something like this
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 what i would like to do is i would like to define soemthing like a variable (Test_name) or in enviroment variables and put that variable in different lines in my yaml like this below.
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
how can i do that?
You can make use of Cloud Build's substitutions to achieve that, as stated in the official docs .
Following the samples provided in the aforementioned docs, your cloudbuild.yaml
will look like:
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.