Hi @Oliver
Thank you for reaching out to Microsoft Q&A.
Your expectation of having a single Branch Validation Policy that dynamically picks and runs the YAML pipeline defined in the repository where the Pull Request was created is logical, but unfortunately it does not work and is not supported due to Azure DevOps YAML pipeline design limitations. In Azure DevOps, branch policies require a statically defined pipeline, and the pipeline YAML must exist and be registered ahead of time in the Pipelines section. The pipeline compiler resolves the pipeline YAML and repository resources at compile time, which means it cannot dynamically load or substitute the pipeline definition from the PR source repository. As a result, Azure DevOps does not support scenarios where a branch policy pipeline dynamically executes the pipeline YAML from whichever repository triggered the PR, forcing many teams into maintaining multiple pipelines unless a workaround pattern is used.
Refer below points to resolve this issue or use this workaround:
Use a single PR validation pipeline that always runs in the context of the PR repository
Create one central PR validation pipeline and configure it as a Branch Validation Policy for all repositories. This pipeline must always check out self, which automatically resolves to the repository where the PR originates.
trigger: none
pr:
branches:
include:
- "*"
steps:
- checkout: self
- template: /.azuredevops/pr-validation.yml
Store repo-specific logic as templates inside each repository
Instead of dynamic pipelines, move variability into repo-local templates. Each repository defines its own PR logic in a known location, for example:
/.azuredevops/pr-validation.yml
Each repository controls its own build, test, scan, or validation steps:
steps:
- script: echo "Running PR validation for this repository"
- template: templates/build.yml
- template: templates/test.yml
Enforce a convention instead of managing 100 pipelines
Adopt a simple convention that every repository must contain a PR validation template at a fixed path. With this approach:
- You maintain only one pipeline
- You apply only one branch policy
- Onboarding a new repo requires no pipeline creation, only adding the template file
This is the most scalable and maintainable design and aligns with how Azure DevOps YAML pipelines are intended to be used at enterprise scale.