[英]Does Google Cloud Build tag trigger apply to all branches by default?
When choosing Tag based trigger in Google Cloud Build, does that mean that any branch with that tag pushed will trigger the pipeline?在 Google Cloud Build 中选择基于标签的触发器时,这是否意味着推送该标签的任何分支都会触发管道? How can we restrict it to a specific branch, ie only tags pushed to a specific branch will trigger the pipeline (tags pushed to develop branch for example)?
我们如何将其限制在特定分支,即只有推送到特定分支的标签才会触发管道(例如推送到开发分支的标签)?
As of Feb. 2022, I believe the answer to your question is (unfortunately) yes , any time you push a commit with the given tag, regardless of the branch, the build will run.截至 2022 年 2 月,我相信您的问题的答案是(不幸的是)是的,只要您使用给定标签推送提交,无论分支如何,构建都会运行。
As to your second question, it doesn't appear that there are any built-in filtering options for both branches and tags.至于你的第二个问题,似乎没有针对分支和标签的任何内置过滤选项。 (There is no mention of this ability in the documentation for creating triggers .) There is a way to skip builds by including
[skip ci]
in your commit message, but that's not ideal for automation. (在创建触发器的文档中没有提到这种能力。)有一种方法可以通过在提交消息中包含
[skip ci]
来跳过构建,但这对于自动化来说并不理想。 Depending on the constraints you have on your branch structure or tagging scheme;取决于您对分支结构或标记方案的限制; if those are flexible, you might be able to use a different set of tags on your develop branch.
如果这些是灵活的,您可以在开发分支上使用一组不同的标签。
One last option would be to add a bash
build step at the start of the build to check the name of the branch (built-in substitution BRANCH_NAME
) and kill it if it doesn't match some criteria.最后一个选项是在构建开始时添加
bash
构建步骤以检查分支的名称(内置替换BRANCH_NAME
)并在不符合某些条件时将其终止。 It's a bit hacky, but that's sometimes necessary with Cloud Build.这有点 hacky,但对于 Cloud Build 来说,这有时是必需的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.