Search code examples
gitvisual-studio-2013tfsbuildpull-request

Team Foundation Server 2013 trigger build for pull request


How to configure TFS to run a build (which is a CI build) for every pull request (when is created and updated).

The scenario that I would like to have is that when a developer completes its work and pushes a branch to GIT (on TFS) it would be nice to check if the build actually compiles and all the tests are passing.

I can create a build for a branch that exists and monitor changes there but how to configure this for branch that will be created later and how to trigger this build when pull request is created.


Solution

  • You can use wildcards in the branch name. So if you create your pull request branches on the server with a naming pattern to them, such as "pr-myrequest", you can add that to the server's CI settings:

    Wildcard in Branch names

    There is a little blurb on this topic in the guidance on MSDN.

    enter image description here Git: Specify the repository and the branches that contain the files that your build process requires.

    enter image description here Tip


    In the list of branches monitored for continuous integration (CI) and rolling builds, you can use wildcards. For example, you could specify refs/heads/feature* to monitor the refs/heads/featureA and refs/heads/featureB branches.

    You can use a / in the branch naming, which may be provide a clear way to name the branches. This would lead to: refs/heads/pr/* as an include and your branch names would have to be prifixed with pr/branchname to be built automatically.