gpt4 book ai didi

azure-devops - 我如何在 azure 管道中通过分支 AND 标签触发?

转载 作者:行者123 更新时间:2023-12-03 23:27:42 27 4
gpt4 key购买 nike

我想创建一个 azure 管道,这样当我推送到分支(开发) 标签(测试*)时,管道将被触发。但是,当我推送到没有标签的分支(开发)时,管道会被触发,这表明在推送到(开发)分支时正在执行触发器 (测试*)标签。
例子:

trigger:
branches:
include:
- develop
- refs/tags/{test*}
仅当推送到(开发)分支 并且 引用(test*)标签时,如何才能触发触发器?

最佳答案

根据 Triggers 上的文档

When you specify a trigger, it replaces the default implicit trigger, and only pushes to branches that are explicitly configured to be included will trigger a pipeline. Includes are processed first, and then excludes are removed from that list.


我认为文档中缺少(或只是令人困惑)的是,满足给定部分(分支、路径、标签)中包含的任何 1 项的项目都为该部分列出,如果它们满足该部分的任何 1 条排除条款,则将其删除。 如果使用了所有三个部分,则 除外。那么以下注意事项适用:

If you specify tags in combination with branch filters that include file paths, the trigger will fire if the branch filter is satisfied and either the tag or the path filter is satisfied.


概括
首先创建 include: 集合,然后从该列表中删除 excludes
部分是 编在一起 (branches OR tags) , (branches OR paths) 除非 使用所有 部分,那么它们是 (branches AND (tags OR paths))考虑到这一点:
如果您只想继续使用分支部分,则需要使用从列表中删除所有不需要的分支并仅显式包含标记 ref(视为分支)的选项。
包含标签并排除不需要的分支模式
trigger:
branches:
include:
- refs/tags/test*
exclude:
# a list of the branches for which you don't want to trigger
- master
- features/*
- bugs/*
- hotfix/*
如果您不限于仅使用分支部分,那么使用所有 3 个部分将通过包含 develop 分支和 test* 标记但排除 所有 路径来实现。
包括标签和所需的分支,但排除该分支上的所有路径
trigger:
branches:
include:
- develop
tags:
include:
- test*
paths:
exclude:
- /*
第二个选项基本上是 shouldFire = (branch == develop && (tag == test* || false)) 相当于 shouldFire = (branch == develop && tag == test*)

关于azure-devops - 我如何在 azure 管道中通过分支 AND 标签触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60154840/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com