Pipeline Pull Request Pain on ADO?

I ran into this issue a couple of times recently, so here’s my notes on the matter.

I’ve needed to make a YAML pipeline on Azure DevOps, using ADO Git hosting. It’s not the edgiest stack out there, but as a consultant it’s rare that you get to choose the tools you use. Sometimes you just need to get something automated today. It’s easy to set up pipeline triggers from changes in the Git repository:

trigger:
  branches:
    include:
      - '*'

Later on, one wants to ensure that a job runs in Pull Requests, so that people can get feedback on those PR’s before they get merged: it’s a powerful way to go from “LGTM” to”let’s fix that vulnerability first”.

pr:
  branches:
    include:
      - main
      - feature-*

It’s possible to spend a lot of time wondering why this doesn’t work. Here’s the thing: presently, it doesn’t work for Azure’s Git hosting. You’ll need to go to the Repository in Azure DevOps and set up a Build validation policy. This is a pointy-click change, but you can use the Azure CLI if you want a hands-off workaround.

I can empathise with the Azure DevOps team here: they’ve had to evolve this product over 17 years to keep up with changing fashions in development. This feature hasn’t been migrated to YAML yet. The world has changed a lot, Enterprise customers are looking for stability, and there’s a workaround to keep the pipelines flowing.

DevOps New Zealand