我有两个存储库,
Repo A
(带有 YAML Pipeline A
)和 Repo B
(Repo A
的依赖项以及独立产品),都位于 Azure DevOps 的同一项目中。现在我想运行 Pipeline A
并处理两个存储库中的任何更改。因此我使用了多仓库触发器,但这仅适用于Repo A
的主分支。
我们在两个存储库中都有多个发布分支,我想配置管道以在
Repo A
的相应发布分支发生更改时运行 Repo B
的发布分支的构建。我还想在主分支发生变化时运行管道。
我尝试将其添加到
Repo A
的主分支:
resources:
repositories:
- repository: self
type: git
ref: refs/heads/master_A
trigger:
branches:
include:
- refs/heads/master_A
- repository: Repo B
type: git
name: Repo B
ref: refs/heads/master_B
trigger:
branches:
include:
- refs/heads/master_B
并将其发送到
Repo A
的发布分支:
resources:
repositories:
- repository: self
type: git
ref: refs/heads/Release-A
trigger:
branches:
include:
- refs/heads/Release-A
- repository: Repo B
type: git
name: Repo B
ref: refs/heads/Release-B
trigger:
branches:
include:
- refs/heads/Release-B
但是这样,它仅在
master_A
、Release-A
或 master_B
发生变化时运行,但当 Release-B
发生变化时,它不会运行
根据您的 YAML 示例,我可以重现相同的情况。它仅在 master_A、Release-A 或 master_B 发生更改时运行,但在 Release-B 发生更改时不会运行。
这是预期行为。
请参阅此文档:多个回购触发器
触发管道时,Azure Pipelines 必须确定应使用的 YAML 文件的版本以及应签出的每个存储库的版本。如果对自身存储库的更改触发了管道,则触发管道的提交将用于确定 YAML 文件的版本。如果对任何其他存储库资源的更改触发管道,则使用自存储库默认分支中的最新版本的 YAML。
如果是对self仓库的commit,则会根据提交确认对应的YAML文件触发pipeline。所以master_A,Release-A可以触发Pipeline。
但是对于资源存储库,它根据Self Repo的默认分支确定要使用的YAML版本。因此,它将根据master_A中设置的Repo资源分支(master_B)触发管道。
您可以导航到 Azure Repo -> Branches 来检查默认分支。
如果需要使用Release_B分支来触发Pipeline,则需要将Default Branch更改为Release_A。
总结如下:
当您将默认分支设置为master_A时,以下分支可以触发管道。
master_A Release-A master_B
当您将默认分支设置为Release_A时,以下分支可以触发管道。
master_A Release-A Release-B