Posted by Will on Tuesday, April 29, 2008 at 4:12 PM

Previously on Adventures of a Lead Programmer in a One-man Shop -
"No, please, I can't take it anymore.  I'll do it.  I'll put my code in source control.  I can't bear the .zip file shame any longer.  Just leave me enough money for milk and crackers.  What?  It's free?!?  And easy?!?  You had me at free..."

It's official.  I've begun wriggling out of my inferiority complex and scrambling up toward a shinny, new Superiority Complex.  In my previous post I said that I wanted to couple my source control solution to a Continuous Integration server that will compile my latest bugs edits into a software release.  When researching continuous integration solutions the two that I heard mentioned most often were CruiseControl.NET, an open source project from ThoughtWorks, and TeamCity from JetBrains.  CC.NET is free and JetBrains offers a free professional version so they both passed the first test.  My sense from snooping around on the web though was that TeamCity would be easier to configure.  I can't say if TeamCity was easier than CC.NET because I didn't try both, but I can say that TeamCity was easy.  There were a couple of points I found confusing though.  I've detailed them in the guide below.  I went through the actual setup twice, but if you find any errors to fix or tips to add please let me know. 

This guide is intended to be used in conjunction with the TeamCity documentation.  I have included the relevant links below.  The guide covers installation of TeamCity and installation and configuration of MySQL (also free, of course) to serve as a back end for TeamCity.  For completeness I've included the Subversion setup steps at the beginning.  Refer to Craig Shoemaker's Subversion episode for more details.  On the first run through I set up TeamCity on an instance of Windows 2003 running locally on Virtual Server 2005 R2.  The second setup was on a remote Windows 2003 server that will be used for production.  Windows 2003 is not a requirement.  All of this can be configured on a single machine (i.e., your desktop machine). 

  1. Installed Subversion using SVN 1-Click Setup option. NOTE: During the install I skipped the Tortoise installation step because the bundled version is not the most current.
  2. Installed the current version of Tortoise.
  3. Installed TeamCity 3.1 Profession Edition following their installation documentation.
    • During the setup I chose 8080 as the port because I already had IIS installed using port 80.
    • For the rest of the installation I clicked through, accepting all of the defaults including for the Build Configuration dialog at the end.
    • Logged in for the first time to accept the license agreement and create the administrative account.
  4. Setup MySQL for TeamCity following their documentation.
    • Downloaded MySQL Community Server.  I chose the default typical installation type.
    • At the end of the installation when prompted with the database configuration I chose Detailed Configuration. 
    • I accepted the defaults until I reached the Concurrent Connections option.  I chose Manual Setting and set the value to 5.  Nothing magical, I just picked the lowest one since I'll only be using this for TeamCity.  You can also manually enter any number.
    • On the Default Character Set option page of the wizard I chose the Manual option and set the value to utf8, as suggested in the TeamCity docs. 
    • On the security screen I checked the box to allow remote access.
    • I accepted the default settings on the rest of the pages in the setup wizard.
    • If you make a mistake or want to change the settings later the configuration wizard can be accessed from the start menu (Programs > MySQL > MySQL Server 5.0 > MySQL Server Instance Configuration Wizard).
  5. Downloaded and installed SQLyog MySQL GUI - Community Edition.  Yep, it's free.  I've used it before and recommend it.  This will be used to create and manage databases in your installation of MySQL. 
    • After installation I connected to my instance of MySQL with SQLyog using the root credentials that I specified in the setup.
    • I created a new database for use with TeamCity (DB > Create Database).  I named it...wait for it... TeamCity and set the character set to utf8.
    • I used the User Manager of SQLyog to create an account on the MySQL instance under which TeamCity will access the database.  The User Manager is found in the Tools menu or by clicking the User Manager button on the toolbar.  I set the account name to...you guessed it... teamcityuser and granted full permissions because at the time I had no idea which privileges were necessary.  Certainly it will need Select, Insert, Update, Delete, and Create to create the supporting tables.  I wasn't sure if it would need Drop, Alter, and Grant for the setup as well.  I'll restrict them later once I've got everything working. 
    • At this point I connected to my instance of MySQL using the new credentials to verify everything was working.  If you're following along notice that the tables directory in the newly created teamcity database is empty.
  6. Downloaded and configured the MySQL JDBC driver.  The JDBC driver allows TeamCity to connect to the MySQL database.
    • The TeamCity documentation says to put the MySQL connector jar in the WEB-INF/lib of TeamCity's web application.  The MySQL connector jar file name is mysql-connector-java-5.1.6-bin.jar and is found at the root of the unzipped directory.  I copied it to C:\TeamCity\webapps\ROOT\WEB-INF\lib of my installation. 
    • The next step is to modify the database.mysql.properties file which is found in the C:\Documents and Settings\<account name>\.BuildServer\config directory.  Before renaming and modifying the file as directed in the setup I made a copy of the file as a backup.  I opened the renamed file in notepad and made the following changes:
      1. connectionUrl=jdbc:mysql://localhost/teamcity
      2. connectionProperties.user=teamcityuser
      3. connectionProperties.password=the password I chose
      4. uncommented the connectionProperties.characterEncoding=UTF-8 line by removing the leading # character
    • Saved the changes and closed the file. 

After making the changes I restarted the server.  I opened a web browser on the server and navigated to localhost:8080.  I was prompted to accept the license agreement again and had to recreate the administration account because the old local data store had now been successfully replaced with MySQL.  You'll also notice at this point if you've followed along that SQLyog will show the supporting tables have been created in the database you made for TeamCity.

Now what? 

Next I need to configure TeamCity to automatically perform a build of the code from my source control repository.  I'll cover that in the next thrilling Adventure of a Lead Programmer in a One-Man Shop.

Comments [2]     Categories: Continuous Integration | Source Control              
Posted by Will on Friday, April 25, 2008 at 5:00 PM

Good gravy, people.  Why didn't you tell me is was this easy to use source control?  Leave it to Craig Shoemaker and his Polymorphic Podcast to, as Denzel Washington's character in Philadelphia said, "Explain it to me like I'm a four-year-old."  I listened to his series on Design Patterns in March of 2007 and it was a revelation.  He produced a show in August of last year called Subversion Quickstart for .NET Developers that I didn't listen to at the time but made a mental note to go back to.  I'm embarrassed to say this, but up to this point I've been using .zip files as my caveman-esque source control system.  In my defense though, it's not like I didn't know what source control was or have access to it.  Visual Source Safe has been available to me for several years.  However, based on everything I'd heard a better alternative would be to print out my code and hide the reams of paper under my mattress.  So here I've been with a growing pile of .zip files and an inferiority complex.  The reason I finally returned to the topic was the browbeating I was getting from magazine articles I've been reading about Agile Programming methods.  "You are using source control, aren't you?", they asked.  I nodded, made up an excuse about having to go turn off my headlights, and pulled up Craig's Quickstart.  It was just what I expected - he made it crazy easy. 

The next question was how can I apply this to my day job?  I knew setting up a source control solution for work would be easy.  I've got access to all the servers I would need for that.  But what about HappyFish?  Whatever I found I wanted it to be:

  • On a remote site for easy access
  • Trustworthy with respect to backups and security
  • Free for closed source projects

SourceForge would probably have been the answer if not for the closed source requirement, but I'm not ready to open HappyFish yet.  My hosting provider seemed like a good place to start.  I use webhost4life.  I've heard good things about other hosts, and even tried one, but no other host gives the same level of features that they offer for the price.  And no other host provides as much user control over their set up in a shared hosting environment.  (If you sign up for their hosting and start with this link then I'll get a credit toward my hosting.  Many thanks.)   At any rate, I checked with them and they don't offer a free source control solution.  Undaunted, I searched on and eventually found Unfuddle.  This is another one of those mysteries of the web - 200MB of free, secure, closed source control hosting space. 

There you have it - from .zip files to true source control in zero dollars.  Thanks Craig.  Thanks Unfuddle.  But it doesn't stop there.  This whole mess started with me reading articles about agile programming techniques.  What good is source control with out a continuous integration solution to go along with it?  I found a free solution for that too.  I'll tell you all about it in the next episode.

Comments [1]     Categories: Source Control