Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reuse same build pipeline for different repository on Azure DevOps

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?

like image 402
simoneL Avatar asked Apr 18 '19 09:04

simoneL


People also ask

Can an azure DevOps project have multiple repos?

Specify multiple repositories Repositories can be specified as a repository resource, or inline with the checkout step. The following repository types are supported. Only Azure Repos Git ( git ) repositories in the same organization as the pipeline are supported for multi-repo checkout in Azure DevOps Server 2020.

How do you save a pipeline in Azure DevOps?

Save and queue the build Save and queue a build manually and test your build pipeline. Select Save & queue, and then select Save & queue. On the dialog box, select Save & queue once more. This queues a new build on the Microsoft-hosted agent.

What is the difference between build and Release Pipelines in Azure DevOps?

The Azure DevOps Server provides two different types of pipelines to perform build, deployment, testing and further actions. A Build Pipeline is used to generate Artifacts out of Source Code. A Release Pipeline consumes the Artifacts and conducts follow-up actions within a multi-staging system.


2 Answers

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://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

like image 144
4c74356b41 Avatar answered Oct 07 '22 20:10

4c74356b41


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://docs.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."

like image 21
Carlos Quintero Avatar answered Oct 07 '22 20:10

Carlos Quintero