1
votes

We have a feature branch were development is done and we want to do a pull request when merging to develop branch. As part of Pull Request there is build validation. I created a separate build definition for building feature branches

enter image description here

enter image description here

Since I only what feature branches to be build by this build definition the only option i have it use "feature/*" under "Enable continuous integration".

The problem with this approach is that the build is triggered twice once during check in another during pull request. This I feel is a way of time and resources. I would prefer that the build definition ran only during pull request and built the feature branch.

If my approach in configuration is gone please suggest.

1

1 Answers

1
votes

Remove the CI trigger from the build, instead of this, click on "Agent job 1" and in the Additional options => Run this job and choose Custom condition using variable expressions and enter this:

startsWith(variables['System.PullRequest.SourceBranch'], 'refs/heads/feature')

enter image description here

Now the PR build will be triggers automatically but the build will run only if the PR branch is feature branch and not something else (if another branch will be create PR to develop there is not will be automatic build and also if will queue this build manually he not will be finished).