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/*
Git Feature Branch Workflow is branching model focused, meaning that it is a guiding framework for managing and creating branches. Other workflows are more repo focused. The Git Feature Branch Workflow can be incorporated into other workflows.
Feature branches allow you to share code before you merge it into master. For example, you might need code that another developer is currently working on, and so isn't available in master yet. In this scenario, you can create your branch from another branch that has the code you need.
What is a feature branch? A feature branch is a copy of the main codebase where an individual or team of software developers can work on a new feature until it is complete. With many engineers working in the same code-base, it's important to have a strategy for how individuals work together.
A release branch is created from develop. Feature branches are created from develop. When a feature is complete it is merged into the develop branch. When the release branch is done it is merged into develop and main.
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
At this time this is not possible. You have to define a default branch. TeamCity takes it into account when it calculates changes in the build in the feature branch and in many other places. As a workaround you can modify your build script to do something different when it is run on a default branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With