Search code examples
azure-devopsazure-repos

Add reviewer automatically based on condition not coming from changes


Is there a way to add in a Pull Request certain reviewer/s based on external parameters outside from is changed certain files?

Examples:

  • Add X reviewer if PR made from 08:00 to 17:00 and Y if PR made from 17:00 to 21:00
  • Add X reviewer if there is some file deleted
  • Add X reviewer each 10 PRs
  • Probability to add X reviewer of 5%

Solution

  • There's no way to specify such rules using the Azure DevOps portal, but you can use webhooks to trigger an application (e.g. Azure Function) where you programmatically add the required reviewers to the PR based on your conditions.

    Available pull requests events are the following:

    Webhook trigger events

    See Use Azure Functions to create custom branch policies to learn how to create a basic Azure function to listen to Azure Repos events and how to configure a service hook for PR events.