我的问题是,考虑到下面的yaml文件,如果我正在更改"dir: process/ Cloud“的任何文件,云构建会在触发时依次运行所有步骤。这会导致浪费时间。
我希望只有这个步骤在cloudbuild中运行,对此已经在该目录的文件中进行了更改。我应该怎么做才能做到这一点?
这是我的cloudbuild.yaml文件:
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 发布于 2020-04-08 07:04:29
使用您的用例,最好的方法是有不同的触发器(用例中的3个)来侦听不同的标记或分支,每个特定于您想要侦听的文件更改。目前,当某个文件更改不可用时,使Cloud步骤执行。
发布于 2020-06-29 12:21:42
您不能通过一次云构建来完成这一任务。您可以做的是使用-包含-file选项创建三个不同的构建触发器。我认为用分支或标签完成与我在另一个答案中看到的相同的事情是不方便的。有关更多细节,请阅读文档。
您的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发布于 2021-04-24 18:16:22
如果你想用gcloud CLI做这件事
gcloud beta builds triggers create cloud-source-repositories \
--repo=REPO_NAME \
--branch-pattern=BRANCH_PATTERN \ # or --tag-pattern=TAG_PATTERN
--build-config=BUILD_CONFIG_FILE \
--substitutions=_VARIABLE="VALUE"\
--included-files "DIRECTORY_NAME/**"注:-
-包括-文件“目录_name/**”将递归地检测所有目录和文件。
-包括-文件“目录_name/*”将只查找该特定目录中的文件。
例子:-
gcloud beta builds triggers create cloud-source-repositories \
--repo=test-repo \
--branch-pattern=master \
--build-config=workflows/cloudbuild.yaml \
--substitutions=_REGION="asia-southeast1"\
--included-files "src/**"https://stackoverflow.com/questions/61011558
复制相似问题