git - Azure DevOps : Pipeline Trigger CI build on branch in different repositories

标签 git azure azure-devops azure-pipelines azure-triggers

我们如何从一个存储库中的提交触发管道到另一个存储库中的管道?

这基本上是这里详细提到的尚未解决的问题:

https://developercommunity.visualstudio.com/content/problem/891431/not-able-to-trigger-ci-build-on-branch-using-pipel.html?inRegister=true

官方文档没有明确说明是否可能 https://learn.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#pipeline-triggers

最佳答案

此功能仍在开发中。 Azure DevOps 服务很快就会提供对 YAML 管道的多存储库支持。

此功能将支持根据多个存储库之一中所做的更改来触发管道。请查看Azure DevOps Feature TimelineAzureDevOpsRoadmap 。预计将于 2020 年第一季度针对 azure devops 服务推出。

<小时/>

目前,您可以按照以下解决方法使用“构建完成”来实现上述目标(管道将在另一个构建完成时触发)。

假设有存储库 A 和存储库 B。您希望在推送到 A 的提交时触发 B 中的管道。

1,为repo A创建一个空的经典管道作为触发管道,它总是会成功并且不执行任何操作。

2、并选中“触发器”选项卡下的“启用持续集成”,并为此触发管道设置 Bracnh 过滤器,以确保在推送提交时触发此空管道。

enter image description here

3、在Repo B管道中设置构建完成触发器。

在 Repo B edit 页面的 yaml pipeline 中,点击右上角的3dots,然后点击Triggers。然后点击构建完成旁边的+添加,并选择上面在步骤1中创建的触发管道作为触发构建。 (也可以在Repo B的yaml管道中定义管道触发器,管道触发器查看here)

enter image description here

4、如果要构建Repo A的代码,还需要再执行一步在Repo B的管道中配置checkout repo。

在 Repo B 的管道中使用 Checkout查看管道中 Repo A 的代码。请引用以下示例:

steps: 
  - checkout: git://MyProject/Repo A@refs/heads/master # Azure Repos Git repository in the same organization

  - task: TaskName
     ...

关于git - Azure DevOps : Pipeline Trigger CI build on branch in different repositories,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60656386/

相关文章:

azure - 无法在独立区域路径之间移动Azure DevOps

git - Azure Devops API - 如何从 UNC 路径创建并自动完成 pull 请求

docker - 发布构建工件任务结果 'path does not exist'错误

git - .gitignore 仅在本地

git - 如何为 RDS 配置 Elastic Beanstalk

git - 我需要帮助使用本地主机 jenkins 设置 github webhook

git - 如何将 Git 的分支名称添加到提交消息中?

azure - 无法评估使用资源组数据源的 Terraform 模块

azure - Microsoft Graph Powershell - Azure AD SAML 应用程序属性和声明未在门户中更新

azure - 当所有测试用例都通过远程 powershell 作业运行时,如何将测试结果发布回同一个 azure 构建管道中