简体   繁体   中英

Azure devops: Pipeline Trigger CI build on branch in different repositories

How do we trigger the Pipelines from commits made in one repository to the pipeline in another repository ?

It's basically the issue mentioned here in details which is not resolved yet:

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

Official documentation does not make this clear if it's possible or not https://docs.microsoft.com/en-us/azure/devops/pipelines/build/triggers?view=azure-devops&tabs=yaml#pipeline-triggers

This feature is still under development. Multi-repository support for YAML pipelines will be available soon for azure devops service.

This feature will support for triggering pipelines based on changes made in one of multiple repositories. Please check Azure DevOps Feature Timeline or AzureDevOpsRoadmap . It is expected to be rolled out in 2020 Q1 for azure devops service.


Currently you can follow below workaround to achieve above using Build Completion(the pipeline will be triggered on the completion of another build).

Let us say there are repo A and repo B. You want the pipeline in B to be triggered on the commit pushed to A.

1,Create an empty classic pipeline for repo A as the triggering pipeline, which will always succeed and do nothing.

2, And check Enable continuous integration under Triggers tab and setup Bracnh filters for this triggering pipeline, which make sure this empty pipeline will be triggered when commits are pushed.

在此处输入图片说明

3, Set up the Build Completion triggers in Repo B pipeline.

In the yaml pipeline of Repo B edit page, click the 3dots on the top right corner and click Triggers . Then click +Add beside Build Completion and select above triggering pipeline created in step 1 as the triggering build. (You can also define a pipeline trigger in the yaml pipeline of Repo B, check here for pipeline trigger)

在此处输入图片说明

4, If you want to build the code of Repo A, you also need to do one more step to config the checkout repo in the pipeline of Repo B.

In the pipeline of Repo B using Checkout to Check out code of Repo A in the pipeline. Please refer below example:

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

  - task: TaskName
     ...

i am not sure if it's possible yet, but the only way i got this working some time ago (with GIT repos) was to do a git push to the "other" repository at the end of one pipeline which automatically triggered the "other" pipeline

Edit: Maybe you can play around with Azure DevOps Service Hooks, create a WebHook on code pushed and than create a REST API call back to Azure DevOps to trigger the pipeline by using this

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM