Only build feature/* branches

git, teamcity

Solution

The following setup is working for my pre-release builds on TeamCity 8.0.6.

Branch specification (visible when you select "Show Advanced Settings"):

+:refs/heads/hotfix/(*)
+:refs/heads/release/(*)

Default branch: `teamcity-default-dummy`

From my understanding you need to specify a default branch other than the branch you want to exclude. I believe it will trigger on commits to the default branch, regardless of branch specification, but I may be wrong.

I had to create a dummy branch and point default here for my pre-release build configuration, because I just got an error it could not get changes from master branch, which does not exist in my repo. You might not need to do this.

Related, I found this article very useful for setting up git with TeamCity. Although this focuses on git-flow the same concepts apply for any branching model.

Update Feb 2015

Still as of TeamCity 9.0 you need to specify a default branch and the default branch will trigger builds. For this case I recommend creating a dummy branch that will never be committed to, such as in the example above.

Help upvote on: https://youtrack.jetbrains.com/issue/TW-24147

Problem

I am trying to setup a TeamCity build to only build feature branches, and ignore master, develop, etc. I current have this in this in my Branch specification: +:refs/heads/feature/*

Original source