Setting up TeamCity build environment
Tags: continuous integration, NAnt, TeamCity December 6th, 2009We are using CruiseControl.NET as our CI build server for a while now and it is working fine. CC.NET displayed test results of NUnit and included NCover, NDepend, Simian and FxCop reports for code analyzes. Also produced deployment package and documentation. For build script we are using NAnt which configuration is stored in source control along our projects so all can be controlled in one place. There are only few cons with Cruise Control – it’s based on XML configuration and it doesn’t include proper account management with access control.
So I thought I would try some other CI server and because I heard lot about TeamCity I decided to give it a shot.
Firstly, installation of the TeamCity was smooth and I got it running quickly. Internally it’s based on Java and runs on built-in Tomcat server. By default it uses a internal storage engine but it’s strongly suggested that in production it should be reconfigured to use some proper database like MSSQL or MySQL. I chose MSSQL because it was already installed on the server. I followed instructions on the documentation and got it running.
Next thing to do was to get it to build one of our projects. It was pretty easy through the administration panel. But by default it didn’t include any reports, just the build action. So I started googling on how to include NUnit test results. This was the most time consuming task, because there were many possible solutions for that based on the version of the TeamCity. One option was to run tests through TeamCity own NUnit runner. But this wasn’t the option because I didn’t want to alter my build scripts for that. My goal was to get it to run without changing any of the existing NAnt build scripts. Digging some more, I found that it also included NAnt task which did it all internally, but it had to be included in build process which still required some minor changes in scripts. But it didn’t required any external dependencies outside the build server so this was an option. When I was done with it, I discovered (yeah, dumb me) that NUnit support was already included in the latest version of the TeamCity (v 4.5.5), this can be configured from the Build Runner configuration tab. I just had to specify what testing framework I am using and where test results can be found. So, woilaa, tests showed up nicely! But then I noticed that number of tests was doubled in the UI. Viewing log files, I noticed that it analyzed tests results twice. So I removed all references to the test report files from the configuration and just specified which testing framework I’m using and it seemed to fix this.
With NCover, NDepend, Simian and FxCop reports it was fairly easy – I just had to edit one TeamCity XML configuration file to create a new tab for the reports and specify the path to the report file which were under the artifacts directory where were stored all the artifacts that build created (test results, reports, deployment package and so on). Our build scripts already generated nice full reports so no extra work was needed here. Although, I cannot take the credit of these scripts, they were initially created by Marek.
Another nice feature of the TeamCity is that I can now create different build configuration per project. With CC.NET there was only one build configuration which was triggered on every commit to the source control. But now I created multiple build configuration. On every commit it just ran all the tests and did the deployment, because it wasn’t time consuming, a few minutes total. And the code analyzes and documentation building process now runs daily, because it can take a lot of time to generate all those reports. Actually there are plenty of options to configure build triggers. Starting with simple schedule intervals to complex ones with dependencies on external resources or on other builds.
Also I can now use proper user account system which can be integrated with source control commits through user linking. I can easily create new users and give access only to specific projects and configuration. There are also plenty of configuration about e-mail alerts. I can send alerts also to my twitter account or even to my NabazTag