Has anyone experienced setting up a build validation pipeline on an Azure DevOps branch, where the YAML is hosted in a different repository than the repository for which the branch policy is set?
Example:
The validation that needs to be performed is exactly the same for the mentioned repositories. Therefore, the reason we want to set it up this way is to avoid each repo B, C, D, etc. having its own YAML file.
We have tried to set up the above, but we are encountering a problem. Although the build validation is correctly displayed for pull requests to the main branch within repo B, C, D, etc., the pipeline is not automatically triggered.
Additionally, the pipeline is not executed when we click the "Queue" button in the PR overview. Simply nothing happens; no pipeline run, no feedback, nothing is visible anywhere, and the button remains clickable (see the image below).
Below a bare-bones examples of the YAML in repo A that reproduces the issue:
name: $(date:yyyyMMdd)$(rev:.r)
pool:
name: 'default'
pr:
branches:
include:
- main
jobs:
- job: AssertPSRule
steps:
- task: PowerShell@2
inputs:
targetType: inline
script: |
Write-Host $(Build.Repository.Name)
I do understand the idea and motivation for your approach, but I'm not 100% that will work - the main problem is how to checkout the source code in repositories B, C or D without some hacks or workarounds.
I suggest you create reusable stage or job templates in repository A that can be easily reused in the other repositories. Or, as an alternative, create some sort of base pipeline (using extends templates).
Example of a base pipeline in repository A:
parameters:
- name: foo
type: string
jobs:
- job: AssertPSRule
steps:
- checkout: self # checkout the repository that contains the pipeline
- task: PowerShell@2
inputs:
targetType: inline
script: |
Write-Host $(Build.Repository.Name)
YAML pipelines to add to repositories B, C, D, etc:
# my-pipeline.yaml
resources:
repositories:
- repository: shared
type: git
name: A
ref: releases/1.0.0
extends:
template: /pipelines/base-pipeline.yaml@shared
parameters:
foo: '123456'