-1

We are using Azure DevOps to build and deploy and we are using Azure DevOps build templates to improve the quality of the build pipelines. We are using the build pipeline templates like the sample shown below

trigger:
  batch: true
  branches:
    include:
      - "master"

stages:
  - template: ../common/ci-build-python-template.yml
    parameters:
      PythonPath: "./"
      SourcesDirForCoverage: "./"
      UnitTestsDir: "./tests/"

As we have started using this approach, it becomes difficult to manage these templates as those are part of the individual repos. Each of the repo owners owns the responsibility of updating these templates. It becomes harder and harder.

I want to have a common repo (much like a library) that all the repos should refer to. So, templates will be updated once in the common repo and it would reflect across the organization.

Is there a way to have such a common repo from where all other repos will refer the templates?

One Developer
  • 99
  • 5
  • 43
  • 103
  • Have you done any independent research? Reviewed the documentation? This is a very common scenario that is extensively documented. – Daniel Mann Apr 09 '23 at 00:51
  • I came across the article https://thomasthornton.cloud/2021/01/25/templating-azure-devops-pipeline-jobs/ however as per the article, each repo has own template. Can you help me with the reference to have a common template used across multiple repos – One Developer Apr 09 '23 at 15:43

1 Answers1

0

Its possible. You can have some shared git repository, where all templates are stored and then refer to that template from your YAML template. Like this below:

resources:
  repositories:
    - repository: templates
      type: git
      name: Contoso/Central

extends:
  template: template.yml@templates

You might want to use tags, so that you can promote changes more safely and easily revert bad ones. Like in this example:

resources:
  repositories:
    - repository: templates
      type: git
      name: Contoso/Central
      ref: refs/tags/v1.0 # optional ref to pin to

extends:
  template: template.yml@templates

Here is the original source

Baurito
  • 121
  • 1
  • 9