Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTS release pull request build trigger

My team are using the VSTS Build & Release mechanism, combined with pull request branch safety settings, so that code can only be merged in when a pull request is completed.

We are experiencing something odd though, in that when a pull-request is created (and a build is spawned to prove the commit) - the completion of this build triggered by the pull request also indirectly triggers a release because we have a release trigger setup.

This in itself is probably ok, but then what also happens is upon 'completing' the pull request, another build & release cycle takes place!

Is there a way of making VSTS release triggers only kick in when the pull request is completed and merged into the release branch?

Thank you!

like image 964
watdo Avatar asked Aug 02 '17 19:08

watdo


People also ask

How do you trigger a build on Azure DevOps pull request?

Create a pull request trigger You can set up pull request triggers for both Azure Repos or GitHub repositories. From within your project, Select Pipelines > Releases, and then select your release pipeline. Under the Pull request trigger section, select the toggle button to enable it.

How do you trigger a release pipeline after making pipeline?

Select trigger: Set the trigger that will start the deployment to this stage automatically. Select "Release" to deploy to the stage every time a new release is created. Use the "Stage" option to deploy after deployments to selected stages are successful. To allow only manual deployments, select "Manual".

How do you trigger release pipeline from build pipeline Azure DevOps?

Stages filters for pipeline resource triggers requires Azure DevOps Server 2020 Update 1 or greater. You can trigger your pipeline when one or more stages of the triggering pipeline complete by using the stages filter. If you provide multiple stages, the triggered pipeline runs when all of the listed stages complete.


1 Answers

You just need to clone your current build definition and disable the CI build, and then use the cloned build to verify the created PR.

First, change for below settings as below:

1. Clone build.

Click ... button of the CI build -> Clone -> edit the cloned build definition -> disable CI build -> save.

enter image description here

2. Replace the cloned build for branch policy.

Open the branch policy -> edit the build validation policy -> select the cloned build definition instead -> save.

enter image description here

So the workflow will be:

  1. The cloned build will to triggered when the pull request is created/changed.
  2. When the cloned build queued successful, you can complete the PR.
  3. When the PR is completed (changes has been merged), the CI build will be triggerd.
  4. When the CI build queued successful, the CD release will be triggerd.

Now, only the PR is completed and merged into release branch, the release definition will be triggered.

like image 126
Marina Liu Avatar answered Oct 03 '22 22:10

Marina Liu