VSTS release pull request build trigger
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:
- The cloned build will to triggered when the pull request is created/changed.
- When the cloned build queued successful, you can complete the PR.
- When the PR is completed (changes has been merged), the CI build will be triggerd.
- 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.
We can specify a branch filter on the release trigger such that only builds of master will trigger a release. PR validation builds are done in a different branch. When approved and the branch is merged into master, that's the build you want triggering a release.
Annoyingly, they keep moving things around. At the time of this writing, when editing a release, under Pipeline, under Artifacts, on the artifact, there is a circle with a lightning bolt inside, tooltip says "Continuous deployment trigger" - click that. On the right, if the trigger is enabled, you'll see "Build branch filters". Click "+ Add" and select the master branch. Save the Release definition.
As for the build doing different things, we can now set conditions on tasks such that you can have a task only run on PR validation builds or only on master builds.
https://docs.microsoft.com/en-us/vsts/build-release/concepts/process/conditions