I was given the requirement to deploy individual work items (stories and bugs) to PPE and Prod. Business analysts (BAs) would approve a story, and that story would be deployed. The client used a single-branch Git strategy: main was the only branch, and deployments to both PPE and Prod used artifacts from a specific build of main.
After reviewing the standard Git branching strategies, I chose GitFlow to support this workflow. There was one issue: my developers would finally have to follow the branch naming standard, which required the work item ID for the story or bug to be embedded in the branch name. The branch naming standard is as follows:
story/<username>/<work item id>-<work item title as a branch name>
Azure DevOps Git triggers no validation event when a branch is pushed to origin. Within the workflow, the first actionable event where a branch can be validated is when a pull request is created (see Set build validation). The construct used is an ADO pull request validation pipeline. This type of pipeline is associated with the pull request’s target branch (main). It initially runs against the PR source branch when the PR is created. It runs again whenever the source branch is updated.
This post is not a tutorial on how to write a YAML pipeline and a corresponding Python or PowerShell script to validate a branch name. The focus is on the steps to configure a pull request validation pipeline. These are as follows:- Go to Repos → Branches.
- Find the main branch.
- Select More options (⋯) → Branch policies.
- Under Build validation, select Add (+).
- Select the validation pipeline and save the policy.
Appendix A: Pre Push Git Hooks
Git’s pre-push hook (see githooks pre-push) provides a client-side mechanism for validating branch names before they are pushed to the remote repository. It is technically feasible as a DevOps engineer to author a script that creates a pre-push Git hook to validate the branch name.
Most DevOps engineers know it is nearly impossible to get a development team to comply with per-laptop mandates like pre-push Git hooks. Even if there were ninety-nine percent compliance, a pull request validation pipeline would be required to ensure the branch name follows the standard.





