Integrate TeamCity with Git Flow
Git Flow is a very strict branching model, which is often used in projects that adpoting the feature branches strategy.
It provides some command lines to help the developer to save time in switching on/off branches. The branch names follow a set of convention, such as feature/*** for feature branches, bugfix/*** for bug fix branches, develop as the trunk branch and master as the production branch. It’s very easy to config the CI tools to monitoring the branch changes, and kick off the build-test-package process. We use TeamCity as the CI tool to explain how to configure CI pipelines for different kinds of branches.
Configure pipelines
Configure pipeline for Master
- Create a project in TeamCity, and configure the repo Url.

- Configure the project name as
TeamCity GitFlow, and set build configuration name toMaster. Now we have a new project with a build for themasterbranch changes.
Configure pipeline for Develop
- Copy the Master configuration to create another one for
developbranch.
Set the names as follow:
Make sure they have different VCS roots:
Configura pipelines for features and releases
- Then create
Features-Bugfixesbuild configuration by coping theDevelopconfiguration; createReleases-Hotfixesbuild configuration by coping theMasterconfiguration. We will have 4 build configurations as below.
Now the Features-Bugfixes and Develop share the same VCS root; Releases-Hotfixes and Master share the same VCS root.
- Edit the vcs root for
Features-Bugfixes. Change theVCS root nametohttps://github.com/qszhuan/teamcity-gitflow-integration.git#refs/heads/features-bugfixes, and edit the Branch specification as below. When clickSave, there are two options: create a separate one or override the current one as it’s used in two places(Features-BugfixesandDevelop). choose to create a new one.
- Edit the vcs root for
Releases-Hotfixes. Change theVCS root nametohttps://github.com/qszhuan/teamcity-gitflow-integration.git#refs/heads/features-bugfixes, and edit the Branch specification as below. Finally we will get 4 vcs roots.
Disable default branch build for features and releases
- The last step is to change the
Version Control Settingsto untick theAllow builds in the default branchoption forFeatures-BugfixesandReleases-Hotfixes.
Test and see the result
Now it’s done. Try to create feature branches or bugfix branches to check the CI pipelines. This is one sample:
Version Control settings
Now we have a skeleton config for Git flow. we can save the project configuration into a repo. so that we can reuse it to generate settings for other projects.
It’s better to create a separate repo to store the teamcity settings. If you are using TeamCity 2017 or later, you can store
blog comments powered by Disqus