One of the great new feature of TeamCity 9 is the possibility of Storing project settings in Git and Mercurial.
When you develop software it is primordial to be able to reproduce successfully builds. To achieve that goal you need for sure first to version the source code. But too often the build scripts are forgotten! Especially when the build scripts are created with such a great tool that is TeamCity.
So we want to keep the source code and the configuration of the build server quite near. So that we are sure we can always rebuild a previous version of the software.
What we don’t want is to have a mixture of source code and build configurations. To achieve that goal we can use the Git possibility to create orphan branch
git checkout –orphan teamcity/settings
Then we remove all content from the old working tree, normally your current source code. No worries, the other files are kept in the other branches!
git rm -rf .
We add a ReadMe.md explaining that this branch is about storing the build server settings and we make a first commit
git add ReadMe.md
git commit -m “Initial TeamCity build settings commit”
And finally we push that to the origin git repository
git push origin teamcity/settings
Now on your TeamCity server you can follow the instruction in Storing Project Settings in Version Control to define that TeamCity must version all changes which are done to your project.
We do it on the top most project so that we get all stored in our Git repository.
To achieve that we define a new TeamCity VCS Root pointing to our newly created orphaned branch; teamcity/settings and finally click the Apply button.
After some seconds you will get in your Git repository a second commit done by TeamCity containing all the configurations files!
Nice new feature!