So you want to use Continuous Integration!

Alright, this would be among the better decisions you would have taken in your project. Good for ya. Well… what next? This is what happened to me lately. Whenever a new thing comes in town, like a pragmatic programmer I do not get on the “Wow this is awesome” wagon until I have done some homework over it. So for Continuous Integration (hereafter mentioned as CI), I looked around the cloud and found several options. One option that is obvious was CruiseControl. It has been used for quite some time in the developer community both .NET and in Java (and others may be). Not sure if it is just me on this, but I found configuring and getting in running for my project became a project in itself. I was basically sitting in front of my laptop trying to get my local svn server, CruiseControl  and few other bells and whistles that come with it to try talk to each other. Not straightforward.

Now you can certainly argue like, Ohhh commmmon man, you are a developer and nothing is straight forward anyways, CruiseControl is configurable in just a snap by editing xml files here and there, starting the service etc. But really I feel things like CI, Source Control which are used to enhance the efficiency of a team, should not become a management task in itself. It should just be easy to setup and get going. And so there is a relatively new kid in town Hudson. It is written in Java by Kohsuke Kawaguchi of Sun. I believe its only his brain into this tool and that makes it consistent throughout. I am mainly .NET guy and needed to get my C# projects into hudson. So here is what I had to do to get Hudson talk to my other companions on my laptop –:

  1. If you are completely Java agnostic, and happen to have no trace of Java on your machine, you would have to download Java atleast version 1.5. Get it from here, http://java.com/en/
  2. Download the latest and greatest hudson.war file from http://hudson-ci.org/latest/hudson.war.
  3. Place the downloaded hudson.war file at some sensible place, well I have it here C:\Hudson.
  4. Open a command prompt and get to folder location which has the hudson.war file. Issue the following command, java –jar hudson.war .
  5. Once hudson is started, visit http://localhost:8080/ on your browser and voila, you should have a wonderful Hudson dashboard smiling at you.

Now to configure my .NET project,

  1. Click ManageHudson in the left navigation links on the Dashboard. Click Manage Plugins (3rd link for the lazy ones, man I am spoiling you). Click the Available tab, Select the MSBuild Plugin and click Install and the very bottom of the page.
  2. Hudson would download everything you ask for and the automatic updates right off the web interface, so no need to upgrade manually.
  3. The MSBuild plugin is basically used to well, build your .NET projects using msbuild.exe. Configure this plugin with your msbuild settings. For really basic settings, Click Manage Hudson again. Click Configure System, navigate to MSBuild Builder section, name it something like MSBuild .NET 3.5 (can be anything really) and the path to the msbuild.exe. Typically the path would be C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe. Hit Save the very bottom of the page.
  4. Now go to the home page, click New Job. Give some Job name. Select “Build a free-style software project” which makes it all configurable.
  5. Since I use Subversion, in the Source Code Management section, I selected Subversion, and gave the repo url as my local repository path(svn://localhost/myproject/trunk/ConsoleApplication8). Local module directory can be set to a period “.”, so that Hudson copies the code files directly into its workspace.
  6. In Build section, click Add Build Step. You should see the Msbuild name you gave in the MSBuild plugin setup. Select that, for the MsBuild file, give the name of your solution like so, ConsoleApplication8.sln. You could give any additional command like arguments to MSBuild if needed for your project.
  7. Hit Save. On the Home Page you would see a link to your project. Click that, you should see a Build Now link in the left navigation links. This would build your project. Wohoooo!!

This is just a basic setting I did in Hudson and got myself CI’ed with Hudson. There are several options to choose from if you know what you are doing of course. I am still overhauling this tool and no doubt it sounds promising. Here are few wonderful links for much deeper help,

http://blog.bobcravens.com/2010/03/01/GettingStartedWithCIUsingHudsonForYourNETProjects.aspx

http://redsolo.blogspot.com/2008/04/guide-to-building-net-projects-using.html

Happy Integrating.

0 Comments:

Post a Comment