Azure DevOps pull request templates
A pull request template is a Markdown or text file in the repository whose text Azure Repos puts in the description of a new pull request: a checklist of tests, documentation and the like that each change should go through. Where the file sits decides when it is used. Below are the rules from Microsoft's Improve pull request descriptions using templates (Azure DevOps Services, Azure DevOps Server and Server 2022), and what to check when a template does not show up.
The default template
Name the file pull_request_template.md or pull_request_template.txt and commit it to the default branch in one of these folders. Azure Repos looks through them in this order and uses the first one it finds:
.azuredevops/.vsts/docs/- the root of the repository
.azuredevops/pull_request_template.md
- File and folder names are not case sensitive.
- Only the files on the default branch (usually
main) count, whatever the source and target branches of the pull request are. - When a template is applied, it replaces the commit messages that otherwise make the default description; Add commit messages on the create page puts them back.
- A template only suggests. To require builds, reviewers or linked work items, use branch policies.
A template for each target branch
A file named after the target branch, in pull_request_template/branches/ under one of the same four places, is used instead of the default for pull requests into that branch:
.azuredevops/pull_request_template/branches/main.md
.azuredevops/pull_request_template/branches/feature.md # feature and feature/*
.azuredevops/pull_request_template/branches/release/october.md # release/october and release/october/*
- The name can match the first level of the branch name (
dev.md,release.md) or follow its levels in folders, up to 10 levels. - Azure Repos looks for one in the folders in the same order; if none matches the target branch, it uses the default template.
Additional templates
Any other .md or .txt file directly in a pull_request_template/ folder (for example .azuredevops/pull_request_template/security.md) is an additional template. It is not applied by itself: on the create page, Add a template lists them by file name and appends the one you pick to the description. A branch-specific template may not appear in that list.
Adding ?template=name.md to the create page's URL uses that template instead of the default or branch-specific one.
When the template is not applied
- It is not on the default branch. A template committed to a feature branch, or still waiting in an open pull request, is not read until it reaches the default branch. If the repository's default branch is not
main, it is that branch that counts. - The folder is not one of the four.
.github/pull_request_template.mdis where GitHub looks; Azure Repos looks only in.azuredevops,.vsts,docsand the root. - The name is different. The default must be
pull_request_templatewith.mdor.txt;PULL_REQUEST_TEMPLATE.mdis fine (case does not matter), butpr_template.mdis not read. - Another template comes first. A branch-specific template for the target branch replaces the default, and a default in
.azuredevopswins over one indocsor the root. - The pull request was not made on the create page. The rules above are those of the web page's create page. A pull request created with another tool gets what that tool puts in the description.
Pull request templates in IntelliJ IDEA
Azure DevOps Pull Requests, a plugin by Lesstep for JetBrains IDEs 2024.1 or later and Android Studio, lists the pull requests of Azure DevOps Services and Azure DevOps Server in an IDE tool window and creates them from your current branch (Git > Create Azure DevOps Pull Request…). From version 1.0.58, the create dialog fills the description with the repository's template by the rules above: the target branch's own template first, then the default, read from the default branch on the server. It says which file it used; changing the target picks that branch's template while the description is left as filled, and Add a template… appends one of the additional templates. Creating, voting, commenting and completing are Pro, with a 30-day trial; the review inbox, the diff and the branch policies are free.
Get it on JetBrains Marketplace
Azure DevOps is a trademark of Microsoft Corporation; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by Microsoft or JetBrains.
More: draft pull requests · required reviewers · linked work items · 日本語