How do I trigger build and test on a pull request in azure devops?

On main page of Azure DevOps go to Repos -> Branches -> (for example) master -> Branch Policies

You can link here build that will that will need to end successfully before you will be able to merge new changes to your branch by pull request.

enter image description here


How do I trigger build and test on a pull request in azure devops?

Build validation should be exactly what you are looking for.

Set a policy requiring changes in a pull request to build successfully with the protected branch before the pull request can be completed. Build policies reduce breaks and keep your test results passing. Build policies help even if you're using continuous integration (CI) on your development branches to catch problems early.

enter image description here

With this setting, once you initiate a PR on the target branch, the Build validation will trigger the build pipeline that you set, only after the build is successful, the PR will be allowed to complete.

Hope this helps.

Tags:

Azure Devops