0
votes

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

2
Hi Triggerring from another repo is not available currently. But you can achieve this using Build Completion as workaround, please check out below answerLevi Lu-MSFT

2 Answers

3
votes

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.

enter image description here

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)

enter image description here

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
     ...
0
votes

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