<p>A few questions so I can better understand your use case:</p>

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

<p>If you plan to run this deploy/build which would create a PR to merge to <strong>Master</strong> for each change in <strong>develop</strong>, then I would recommend to delete the <strong>develop</strong> branch and instead develop directly against <strong>Master</strong>. Configure <strong>Master</strong> with <a href="https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#build-validation" rel="nofollow noreferrer">Branch Policies</a> 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.</p>

<p>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 <a href="https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/create?view=azure-devops-rest-5.0" rel="nofollow noreferrer">Create a Pull Request</a>. This would be run as the last task in the deploy/build.</p>

<p>If you plan to merge to <strong>Master</strong> from areas other than the <strong>develop</strong> 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.</p>

CC BY-SA 4.0
2020-01-29T07:59:41.663Z
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
Pat Long - Munkii Yebee
CC BY-SA 4.0
2019-05-26T21:27:46.947Z
2019-05-26T21:27:46.947Z
AHaleIII
<p>I would look into Azure Functions. Create a gate trigger and enable azure function after a successful release. </p>

<p>References:
<a href="https://docs.microsoft.com/en-us/azure/devops/repos/git/create-pr-status-server-with-azure-functions?view=azure-devops" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/devops/repos/git/create-pr-status-server-with-azure-functions?view=azure-devops</a></p>

CC BY-SA 4.0
2019-05-21T21:18:34.397Z
2019-05-21T21:18:34.397Z
Richard Hughes
<p>I have a classic env. setup like following:</p>

<p>I have 2 branches : Develop and Master.</p>

<p>Is there any way in <code>azure devops</code> to setup the following <strong>rule:</strong></p>

<ol>
<li><p>When a deploy is succeeded on dev environment (defined in the
release pipeline of azure devops) <strong>------></strong> create automatically a <code>pull request</code> to merge <strong>develop</strong> into <strong>Master</strong>.</p></li>
<li><p>or the other one: if a <code>Build</code> of <strong>develop branch</strong> is succeded <strong>-------></strong>
    create <strong>automatically</strong> a <code>pull request</code> to merge <strong>develop into Master</strong>.</p></li>
</ol>

<p>Any help will be appreciated.</p>

<git><azure-devops><build-pipeline><azure-pipelines><branch>
CI/CD pipelines Azure devops automatic merge after deploy release
Haithem KAROUI
# CI/CD pipelines Azure devops automatic merge after deploy release

(Asked by: username_0 on 2019-05-17)

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.

**Tags:** git, azure-devops, build-pipeline, azure-pipelines, branch


---

## 2 answers

### Answer by username_1 on 2019-05-26. Score: 1 | Accepted answer

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](https://docs.microsoft.com/en-us/azure/devops/repos/git/branch-policies?view=azure-devops#build-validation) 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](https://docs.microsoft.com/en-us/rest/api/azure/devops/git/pull%20requests/create?view=azure-devops-rest-5.0). 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.

> **Comments:**
> **username_2**: 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  

---

### Answer by username_3 on 2019-05-21. Score: 1

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>


---

