7

I have a project on Azure DevOps containing multiple forks of the same main repository. I created a build pipeline for that repository which unfortunately cannot be reused for the present forks since a pipeline can only be configured for a single repository.

This solution is not ideal because leads to multiple identical pipelines, one for each fork, and maintaining all of them can be difficult.

Is there a way to use one pipeline for multiple repositories?

simoneL
  • 602
  • 1
  • 7
  • 23

2 Answers2

8

you can create a template file and reference that file from each pipeline, that way you can edit a single file and every pipeline will change.

example how to reuse a step file from different repo

resources:
  repositories:
  - repository: DevOps
    type: git
    name: DevOps
trigger: none

jobs:
- template: vsts/yaml/build.yaml@DevOps
  parameters:
    solutionName: xxx
    registryName: yyy

You can take a look at the official docs for more examples

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
  • 2
    That solves the issue of having duplicated configuration across every repository, which is good but it seems that I still have to create a pipeline for each fork. Is that right? – simoneL Apr 18 '19 at 10:47
  • yes, you can target single build for multiple repositories, unfortunately – 4c74356b41 Apr 18 '19 at 11:13
  • @4c74356b41 where can I reference a template file? I don't find such option. – Mar Tin Aug 01 '19 at 10:55
3

It's on the roadmap for 2019 Q3:

Multi-repository support for YAML pipelines https://dev.azure.com/mseng/AzureDevOpsRoadmap/_workitems/edit/1454026

Update: this is now implemented: https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#triggers

"Triggers

You can trigger a pipeline when an update is pushed to the self repository or to any of the repositories declared as resources."

Carlos Quintero
  • 4,300
  • 1
  • 11
  • 18
  • I believe that work item is about triggers in external repositories not the actual including of templates from external repositories which is already in the public docs - https://learn.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops#using-other-repositories – alv Aug 07 '19 at 08:26
  • 2
    @alv, I'm afraid that I don't understand your comment. My answer (the work item planned by MS) is exactly what the original poster wants (and me too): to reuse the same build pipeline for different repos with CI triggers or PR triggers. Using templates is a half-baked solution that still requires a pipeline for each repo, which can be still a nightmare to support (think changing the name of the template, or adding a parameter, for example) – Carlos Quintero Aug 08 '19 at 15:39
  • In progress for Q4 now. – lindhe Dec 05 '19 at 14:09
  • Did this every make it? – DrBB Apr 28 '22 at 14:19