Using Team City With Git

I love TeamCity, but I had some difficulty with setting up Team City with Git as my vcs so thought I’d log my configuration here. Documentation on the plugin is a bit sketchy and the exceptions raised when testing connections can be horrible, but the native Git plugin in Team City (v5.1+) is still under development so some features are still not completed so I expect things to be a bit rough around the edges.

Mode

I just wanted to my sources to be updated incrementally, being triggered by changes at the host. This requires having the build done on the agent (not the server):

teamcitygit1

 

Note this requires having git installed on the build agent server. Team City is smart enough to find git if you follow default installation of it, but I include git in the PATH for consumption in the build script anyways.

Settings

Now I need to configure what is getting fetched by Team City and setup ssh to talk to github (we host on a private repository there). All development happens on develop branch so I instruct TeamCity to checkout that branch after fetching the data.

Also I need to tell TeamCity about authentication:

teamcitygit2

Authentication

I believe TeamCity still only supports the ‘Default Private Key’ option. I had seen somewhere someone using a Private Key but I wonder if they were using the older git plugin hosted at github.

Anyways, the part that took me a while to understand was this note under ‘Authentication Method’ selection:

Valid only for SSH protocol and applicable to both fetch and push urls.

Uses mapping specified in the file C:\Documents and Settings\TeamCity\.ssh\config if that that file exists. 

I run TeamCity under a user account called ‘TeamCity’, so this is just instructing me where the build agent will go looking when it is doing its work. It is important to note that passphrases aren’t supported yet. The ‘config’ file threw me because I don’t know anything about ssh. I thought that was what my key file should be named (eg. ‘id_rsa’) . The ‘Known Hosts Database’ checkbox is checked because I don’t want it checked…confusing? I thought so too…please don’t ever code an interface with a checkbox that has the label ‘do not check’ next to it. I thought this was telling me not to check the box…silly me! If you do check the box Team City will in fact create the ‘known_hosts’ database in the folder for you.

The ‘config’ file it is talking about can be simply:

Host github.com

Fetching

Team City explicitly fetches no tags (‘git fetch –-no-tags’). I use tagging to marking my versions so when my tags weren’t being found in my script I wasn’t sure what was going on since I knew the tags were on the remote repository. I thought for sure my n00b git skills were causing me pain. Jet brains confirmed that they are not fetching tags. This leaves two options:

  1. Manually call ‘git fetch –-tags’ on the agent; what if I want to clean the directory and have it rebuilt? That seems error prone
  2. Call git within my build script

I went for option 2 and that put me back in business with versioning my assemblies. I actually came across an ssh error so ended up adding this to my config file mentioned earlier:

Host github.com
StrictHostKeyChecking no

This seemed to resolve this error, but I am sure someone could tell me this is a bad idea. Works for now.

As an aside, you can see the command being fired by Team City by following instructions here.

I Hope this helps!


Posted 06-12-2010 12:07 AM by Michael Nichols
Filed under: , ,

[Advertisement]

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)