I have a classic env. setup like following:

I have 2 branches : Develop and Master.

Is there any way in azure devops to setup the following rule:

  1. When a deploy is succeeded on dev environment (defined in the release pipeline of azure devops) ------> create automatically a pull request to merge develop into Master.

  2. or the other one: if a Build of develop branch is succeded -------> create automatically a pull request to merge develop into Master.

Any help will be appreciated.

2 Answers 2


A few questions so I can better understand your use case:

  • How often would this deployment/build of yours be run?
  • Will there ever be any changes going into Master that do not come from develop?

If you plan to run this deploy/build which would create a PR to merge to Master for each change in develop, then I would recommend to delete the develop branch and instead develop directly against Master. Configure Master with Branch Policies enabled that would run a gated build (compile/unit test) before the PR can be merged. This is what my team has been doing for a while now with great success. This change in workflow would prevent the need for having a deploy/build which automatically creates a PR.

If you plan to run this deploy/build less frequently than every change, then I would recommend to use the VSTS APIs and a custom scripting task to automatically create a PR. I believe the scripting task would be fairly similar regardless of whether a deploy runs it or the build runs it. The documentation for VSTS APIs is fairly comprehensive, and I use several of them as part of our pipeline workflows (I use PowerShell). Here is documentation to Create a Pull Request. This would be run as the last task in the deploy/build.

If you plan to merge to Master from areas other than the develop branch, I just want to call out that the PR which will be automatically created by deploy/build could have conflicts and require manual intervention.

  • Would you run any tests more involved than just unit tests in that "Gated Build" that was configured by Branch Policies? Such as some automated browser testing of a deployment? The OPs original scenario didn't move to MASTER until a deployment was successful rather than just a CI build Commented Jan 29, 2020 at 7:59

I would look into Azure Functions. Create a gate trigger and enable azure function after a successful release.

References: https://docs.microsoft.com/en-us/azure/devops/repos/git/create-pr-status-server-with-azure-functions?view=azure-devops

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.