我的问题是,给定下面的 yaml 文件,如果我在“dir: process/cbd-bu-data”的任何文件中进行更改,Cloud Build 会在触发时串行运行所有步骤。这会导致时间的浪费。
我希望只有该步骤在 cloudbuild 中运行,并在该目录的文件中进行了更改。我应该怎么做才能实现这个目标?
这是我的cloudbuild.yaml
file:
steps:
- args:
- beta
- functions
- deploy
- "--runtime=python37"
- "--trigger-http"
- "--entry-point=process_cbd_group_data"
- process_cbd_group_data
- "--region=us-central1"
dir: process/cbd-group-data
name: gcr.io/cloud-builders/gcloud
- args:
- beta
- functions
- deploy
- "--runtime=python37"
- "--trigger-http"
- "--entry-point=process_cbd_bu_data"
- process_cbd_bu_data
- "--region=us-central1"
dir: process/cbd-bu-data
name: gcr.io/cloud-builders/gcloud
- args:
- beta
- functions
- deploy
- "--runtime=python37"
- "--trigger-http"
- "--entry-point=process_cbd_structure_data"
- process_cbd_structure_data
- "--region=us-central1"
dir: process/cbd-structure-data
name: gcr.io/cloud-builders/gcloud
您无法通过一个云构建来完成此操作。您可以做的是使用 --included-files 选项创建三个不同的构建触发器。我认为用分支或标签完成同样的事情并不方便,正如我在其他答案中读到的那样。阅读文档 https://cloud.google.com/cloud-build/docs/automating-builds/create-manage-triggers更多细节。
你的 git 存储库布局:
function_one/
main.py
cloudbuild.yaml
function_two/
main.py
cloudbuild.yaml
function_three/
main.py
cloudbuild.yaml
cloudbuild.yaml
父cloudbuild.yaml的布局:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
cloud beta builds triggers create github build_one --included-files "function_one/*" --repo-name=XXX --repo-owner=XXX --branch-pattern=$BRANCH_NAME
cloud beta builds triggers create github build_two --included-files "function_two/*" --repo-name=XXX --repo-owner=XXX --branch-pattern=$BRANCH_NAME
cloud beta builds triggers create github build_three --included-files "function_three/*" --repo-name=XXX --repo-owner=XXX --branch-pattern=$BRANCH_NAME
子cloudbuild.yaml的布局:
steps:
- args:
- functions
- deploy
- "--runtime=python37"
- "--trigger-http"
- "--entry-point=process_cbd_group_data"
- process_cbd_group_data
- "--region=us-central1"
name: gcr.io/cloud-builders/gcloud
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)