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!
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.
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".
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.
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.
2. Replace the cloned build for branch policy.
Open the branch policy -> edit the build validation policy -> select the cloned build definition instead -> save.
So the workflow will be:
Now, only the PR is completed and merged into release
branch, the release definition will be triggered.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With