0
votes

My goal is to block a PR completion until a change has gone through a CI pipeline and been deployed in a test release pipeline successfully. Additionally, I want to control which CI pipeline builds enter the release pipeline, so release entries don't get added with every PR commit.

I currently have the CI pipeline setup and working and I have a release pipeline working with manual additions.

To solve my problem, I tried to modify the Release pipelines Build Artifacts settings to use Pull request triggers for a specific target branch. Then, in the Release pipeline stage's pre-deployment conditions, I've selected a trigger of "After release" with pull request deployment enabled. However, I'm not seeing releases automatically created.

Is what I want possible? Are there other steps to execute this?

1
Is there any update for this issue? Feel free to let me know if the answer could give you some help. Just a reminder of this.Leo Liu-MSFT

1 Answers

1
votes

How can I block PR completion until a release succeeds in Azure DevOps?

To achieve this, you could add the release pipeline as Status Checks in the Branch Policies:

enter image description here

Detailed steps:

  1. Add the CI pipeline as Build Validation in the Branch Policies for the specific target branch.
  2. Do the same release pipeline settings as you, enable Pull request triggers for the specific target branch and enable pull request deployment.
  3. Add the release pipeline as Status Checks in the Branch Policies for the specific target branch.

Note:

  1. If you could not see the release pipeline in the list when you add the Status Checks:

    enter image description here

    Please try to change the Source type of the release from Build Artifacts to Azure devops repos for the specific target branch, and also enable Pull request triggers for the specific target branch. Then, create a pull request to trigger this release pipeline. After that, we refresh the Branch Policies, we will see the release pipeline.

    enter image description here

    Now, we change the Source type of the release back to Build Artifacts and enable Pull request triggers for the specific target branch and enable pull request deployment.

  2. The reason why you did not see releases automatically created may be that your build pipeline is not triggered by PR (maybe manually).

Mytest result :

enter image description here

If I do not set the release pipeline as Status Checks, just enable Pull request triggers and pull request deployment, it will set as Optional, it will not block PR completion:

enter image description here