Microsoft’s Visual Studio Team Services (VSTS) has become quite a compelling offering for managing software development. Features include source control, build, release, and issue tracking. With the product team working on 3 week sprints, new features are being added frequently.

One feature in particular that VSTS inherited from its on-premise predecessor/sibling Team Foundation Server is gated check-ins. This is a terrific way of keeping the build “green” – you avoid the risk of a developer committing changes that break the build (and that breaking change then ‘infecting’ the rest of the team). Instead their changes are isolated and not actually finally committed until after the build (potentially including unit tests) has passed.

If you use Git version control with VSTS, the equivalent to gated check-ins is branch policies. You can enable one or more of the following branch policies:

  • Require a minimum number of reviewers
  • Check for linked work items
  • Check for comment resolution
  • Enforce a merge strategy
  • Build validation
  • Approval from external services

Build validation uses the built-in VSTS Build services, so what if you’re already using another build server – say JetBrain’s TeamCity for example? Well that’s where that last item “Approval from external services” can come into play.

TeamCity does have some support for building VSTS Git repositories. What it can’t currently do is integrate fully as a VSTS branch policy.

This is the first in a short series of blog posts in which I’m going to describe how I leveraged the VSTS Pull Request Status API and TeamCity’s API via a custom ‘pull request server’ to act as an intermediary between VSTS and TeamCity. With this in place, pull requests must have a passing build before the changes from the branch are allowed to be merged to master.