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?
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