I discovered something interesting today: TeamCity allows you customize what folders are checked out from your source control (we're using subversion). When we were building before, the actual build took about 5 seconds or so but the total length of time was on average a minute and a half. People complained about this and didn't lieke doing personal builds because it took too long (personal builds allow you to send a build to TeamCity and have it try to build with your updates before committing your code. This helps stop people from committing breaking changes). I found that the reason it was taking so long is that we have a lot of stuff under version control, such as our database, the QA test projects, some tools projects, as well as a bunch of other random crap that, while important to the whole project, are not directly used by the particular build configuration we care about for the website. So, after reading the manual, I discovered that I can restrict TeamCity to only check out certain directories. Here's what I did:
My svn root for my project (this is not my real svn tree, duh) is at https://127.0.0.1:8080/projects/trunk and the various parts of the application live in sub folders. I therefore have the following:
https://127.0.0.1:8080/projects/trunk/Application - our web application
https://127.0.0.1:8080/projects/trunk/Database - the database scripts
https://127.0.0.1:8080/projects/trunk/Externals - things like Rhino, MbUnit, etc.
https://127.0.0.1:8080/projects/trunk/Tools - useful tools that we write for application admin stuff
https://127.0.0.1:8080/projects/trunk/QA - our QA department's test stuff (BVT, regression, etc)
So in order to build our web application, everything we need is in Application and Externals. However, I can't just point TeamCity to https://127.0.0.1:8080/projects/trunk/Application because then I don't get Externals. I also can't just have an externals directory on my build agents because then I have to maintain them in multiple places (DRY principle- it's not just for code; it applies to project structure and build scripts too). So, I have to check out https://127.0.0.1:8080/projects/trunk which gives me about 100mb of extra crap that I don't need to build the web application. How do I deal with this?
Under TeamCity's project configuration on the Version Control Settings section, there is a thing that says "edit checkout rules" that, when clicked, will allow you to apply rules to what gets checked out. I clicked it and here is how it works:
You put each rule on its own line. A rule starts with either a + or a -, with + meaning to check out the thing and - meaning not to check it out. You would make rules relative to the root directory, so since my version control settings for the VCS root is set to https://127.0.0.1:8080/projects/trunk, I have to make all my rules relative to that path. Therefore, to exclude Database and save about 45 seconds of checkout time, I add a rule that restricts checkout of that directory. Since the directory is https://127.0.0.1:8080/projects/trunk/Database, I do this:
-:Database
and it now ignores the database (I believe that these are case sensitive). I applied a few more rules and now all that is checked out is https://127.0.0.1:8080/projects/trunk/Application and https://127.0.0.1:8080/projects/trunk/Externals for my main application build. This reduced my build time to about nine seconds on average. Much better. There are other things that you can do here with checkout rules also but I'm not actively using any of them yet.
I have been using TeamCity for a while now, I strongly suggest you check it out. There is a free version with limited numbers of Users (20), Build Agents (3), and Build Configurations (20). You can buy additional build agents individually or you can buy the full version which gives you more features. Check it out here: http://www.jetbrains.com/teamcity/
Showing posts with label Continuous Integration. Show all posts
Showing posts with label Continuous Integration. Show all posts
Tuesday, April 1, 2008
Subscribe to:
Posts (Atom)
