Integrating TeamCity with Team Foundation Server – Part 1

In this cross-platform world, where everything integrates with … well everything, it is not unusual to come across companies that use more than one system for their Application Lifecycle Management. Team Foundation Sever offers a great solution if it comes to ALM. Work Item Management, Build Management, Release Management etc. But there is more available in the field.

This post will focus on the integration of the great build system of JetBrains, TeamCity, with Team Foundation Server. I will talk about setting up TeamCity so that it builds sources from TFS. In my next post I will talk about how to further integrate the two systems to use build artifacts from TeamCity in, for example, Work Items and Test Manager.

Setting up the environment

Let’s start with the set-up of the environment. I created a Virtual Machine where I installed TeamCity. It also required some other components. What I eventually have on my Team City Server is:

I do not run my TeamCity server as a Windows Server but as a console server. When you install TeamCity it asks for a port to run on. I chose 8111. Make sure it is not port 80, because it might conflict with your local IIS. When TeamCity is installed, open a command prompt en navigate to the TeamCity/bin directory and run the [RunAll.bat start] command to start the build server and build agent. After that, navigate to localhost:8111 with your browser and you can get started.

I also set-up a local TFS 2015 server which is part of the same domain.

Creating a simple build

Creating a TeamCity Project

Then we need to build something. After all TeamCity is a build system. Configuration is done from within the browser (just like the Build vNext in TFS 2015). The first thing you need to do is create a project in TeamCity.

image

A project in TeamCity can be compared with a Team Project in TFS. You can group multiple builds within a project. For example a Continuous Integration Build and a Release Build, or a build for System A and System B within your product.

Within the project we create a Build Configuration. A build configuration can be compared with a Build Definition in TFS. The steps to execute, the schedule, the triggers, the solution to build, etc. This is all configured within the Build Configuration.

Sources to build

I created a very (very very very) simple ConsoleApplication as our sample application and checked this in to TFS.
image

Creating the TeamCity Build Configuration

General

Now it is time to create the Build Configuration in Team City. First thing you need to do is fill in the General tab with basic settings about your build.

image

The most important settings are highlighted. The name is important. It tells you something about the purpose of this build. In this case a CI build. The build number format is set default of %build_counter% which is a variable. Only a simple number is not clear enough for me so I prefixed it with the product name (ColorGallery).

The the artifact path. TFS publishes all artifacts to a network share or within TFS. That is a choice you make within the definition. TeamCity does not publish unless you configure this. So in Artifact paths, you point to a location on disk where the artifacts are build (default in the working directory c:\TeamCity\buildagent\work\…

Source Control

After that it is time to configure Source Control

image

TeamCity supports multiple Source Control systems. For now we choose Team Foundation Server as the type of VCS. The [VCS root name] is a name we choose to refer to our root. I chose MAIN to point to the MAIN branch. This is what I configured in [Root] by pointing to the $/TeamProject/MAIN branch. After filling in the TFS URL and credentials you are all set to get sources from TFS

Build steps

Now we need to configure Build steps in order to build something. Quite similar to the Build vNext of TFS, you can choose from components to create your build. I chose [Visual Studio (sln)] as the build step and pointed to my Visual Studio solution

image

Now save your Build Configuration and run ! Check if your artifacts are available with your build.

 

image

Integrating TeamCity with TFS

So we are all set. TeamCity gets sources from TFS and builds. This is integration but we need more. When we use Test Manager, we need to select a build to test against. In our work items we need to select a build number. This is not possible when using TeamCity … or is it?

image

Fortunately we can do some kind of integration, although it is a kind of a hack. Currently the Team Foundation Server artefacts like Test Plans, Work Items, Release Management etc is really tightly coupled with the TFS Build Engine. So, in short, we cannot use TeamCity directly but we need to create a build in TFS that we can use. But if you set up this build in a smart way and create some tooling around it, these two can live happily together.

In my next post I will write about how to do this. You can find the post here:

https://roadtoalm.com/2015/07/17/integrating-teamcity-with-team-foundation-server-part-2/

Resources

Advertisements

3 Responses to “Integrating TeamCity with Team Foundation Server – Part 1”

Trackbacks/Pingbacks

  1. Integrating TeamCity with Team Foundation Server – Part 2 | The Road to ALM - July 17, 2015

    […] my previous post I introduced TeamCity as  an alternative build server to use in conjunction with Team […]

  2. Integrating TeamCity with Team Foundation Server – Part 1 | Dinesh Ram Kali. - August 15, 2015

    […] https://roadtoalm.com/2015/07/16/integrating-teamcity-with-team-foundation-server-part-1/ […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: