3
votes

Is there a way to have VSTS run a build of the PR branch?

I know you can set up VSTS' policies to trigger a build when there is a pull request but this is useless if you cant specify that the branch the PR is being made from should be the one that would need to be built. (I don't want master to build for example, I want my new code to build).

I know you could set up another "dev" branch where you could run these test but that is not desired.

Thanks!

1
What do you mean by this is useless if you cant specify that build to user the PR of the code coming in?Daniel Mann
Edited to be more specific. I want the Travis CI functionally, Check out my PR , build and test it. Cant seem to be able to do that with VSTS.Chéyo
I still don't understand the question. When you set up a branch policy, the default branch in the build definition is overridden with the PR branch.Daniel Mann
Weird. For some reason my PR was only triggering master yesterday. I removed the policy and then added back and its working as you described! ThanksChéyo

1 Answers

6
votes

You misunderstand how branch policies work with regard to build definitions. A build definition specifies a default branch (e.g. the branch that is built if you queue the build manually), and can contain CI triggers on any number of branches.

When you link a build definition to a branch policy and open up a PR, the build definition is run for the PR branch. The default branch is overridden. You can easily validate this yourself by setting up a branch policy with a default branch that builds successfully, then opening a PR containing changes that cause the build to fail.