Published 1 December 2022

YamlAzure DevOpsDevOps

Overview

Working on large programmes with many repos involved can potentially lead to duplication in pipeline logic, here is an easy way to centralise and ultimately share YAML files between repos.

Markup

Adding the centralised repo as a resource is key here:

trigger:
- main

resources: 
  repositories:
    - repository: pe
      type: git
      name: Arceau-PE
      ref: main
  
stages:
- stage: build_release_web
  displayName: 'Build and Release WebSite'
  jobs:
  - template: /yaml/jobs/build-release-website.yml@pe
    parameters:
      environment: $(Environment)
      spn: $(Connection)

But the real magic is the simple "@pe" after the template file reference, this means that the resource named "pe" will be used when looking for the template file.

This is probably well documented but its just something that had managed to escape me so I wanted to share.