Hudson Continuous Integration Server
Hudson makes continuous integration easy and powerful. Though Hudson is a Java project, it can easily build your .NET applications. You configure Hudson easily via the Web interface rather than tweaking XML. With plenty of plugins available to .NET projects, Hudson provides plenty of powerful features.
Kohsuke Kawaguchi, a staff engineer at Sun Microsystems, released Hudson in February of 2005. Since that time, Java developers have adopted Hudson as their continuous integration server in greater and greater numbers. From Feb 1 through Feb 7 of this year, users downloaded Hudson 2855 times. Java developers use Hudson for three major reasons: ease of installation, ease of configuration, and ease of extensibility. Additionally, Hudson handles distributed builds across multiple platforms very well. A single Hudson master can control multiple Hudson slaves installed on different operating systems. My team runs our Hudson master on Linux with a Windows slave when we have jobs that require Windows. Hudson is truly easy and enjoyable to use. Fortunately, through some .NET-specific plugins, .NET developers can have that same ease of use.
Hudson uses an easy plugin model that has encouraged the community to author and submit over 100 plugins to the master Hudson repository. An additional 100 unofficial plugins appear in the Hudson usage statistics. While many of those extensions focus on the Java core of the Hudson community, there are enough Microsoft-specific and general use plugins to make Hudson worth a serious investigation. The .NET offerings include MSBuild, NAnt, MSTest, and FxCop. In addition, Hudson has easy integration with source control systems including Subversion, Git, Team Foundation Server, Visual Source Safe, CVS, and others. See the sidebar entitled, “More Plugins” for descriptions of more useful extensions to the Hudson system.
I will cover the initial installation of Hudson and setting up a complete build for an example project. My project will include integrating with Google Code for source control and source browsing, compiling with MSBuild, executing NUnit tests, publishing test results, and publishing build artifacts.
In order to get started, you’ll need to download a few resources. You should get the latest versions for all downloads unless I state otherwise.
Download Hudson from http://hudson.dev.java.net via the Downloads link on the left side of the page. I will show the installation of release 1.280, but with Hudson releasing as frequently as it does, that will not be the latest version by the time you read this. The link to release 1.280 is at http://shrinkster.com/1497.
The example project uses NUnit as its testing framework. My example for this article will integrate the NUnit console runner with the Hudson build. Download NUnit from http://www.nunit.org/. I’ll use NUnit version 2.4.8 for .NET Framework 2.0, which is compatible with .NET 3.5.
You probably already have the .NET Framework installed. The sample project requires .NET 3.5. If you do not already have .NET 3.5, install it via Windows Update.
Java Runtime Environment (JRE)
You probably already have this installed as well. Unless you changed the default installation location for Java, you can determine your Java version with this command:C:\>java -version
You should see something like:java version "1.6.0_07"
Java(TM) SE Runtime Environment
You can download the latest JRE at http://java.sun.com/javase/downloads/index.jsp and click the download button for “JRE 6 update 12.” Follow the prompts and selections to download the Windows JRE. Once you have downloaded the JRE, launch the .exe file and follow the prompts to complete the installation.
To get Hudson up and running, you will simply start Hudson from a command prompt and then ask Hudson to install itself as a Windows service. Before you start, you need to consider a couple of configurations, which I’ll cover in the next sections.
First, what port would you like Hudson to run on? The default port is 8080, but if you wish to use a different port, you can override the default with the httpPort option as described below.
What directory would you like to install Hudson to? Hudson keeps all files including configuration and workspaces in the same root directory. Be sure to install Hudson on a disk that has plenty of room to handle working copies, compiled binaries, and archived builds. The default installation directory for Hudson is: C:\Documents and Settings\<user>\.hudson
You can override the Hudson home directory using the HUDSON_HOME environment variable as described below.
Open a command prompt and navigate to the directory containing the downloaded hudson.war file. If you want to run Hudson with the default configurations, issue the following command:java -jar hudson.war
To change the directory Hudson works from and the port that Hudson runs on, use this command:java -DHUDSON_HOME=<dir> -jar hudson.war
Assuming that you started Hudson on the default port, verify your Hudson installation by pointing your browser at http://localhost:8080/. You should see the Hudson home page as in Figure 1.
Figure 1: The Hudson home page.
By: Eric Anderson
Eric Anderson is an Agile software developer with Headspring Systems in Austin, TX. You can find him on Twitter at @eric_anderson and on the web at www.testinfected.net.
Monitoring Hudson with CCTray
Most teams like to know about build breaks as soon as possible. CruiseControl.Net users will already be familiar with the CCTray application for monitoring CruiseControl builds. My team enjoys the audio alerts that CCTray provides, especially speech mode. Plenty of other applications exist to monitor CruiseControl builds and most users of CC.Net have their favorites.
While there are tools for monitoring the variety of Hudson RSS feeds, Hudson also publishes the standardized CruiseControl XML format. This means that, theoretically, the Hudson server can look just like any other CruiseControl server to a monitoring application like CCTray. I use CCTray to monitor my Hudson installation, and it works just fine.
Hudson publishes the relevant XML to:
Simply configure your CCTray with this URL, and the CCTray app will list all of the existing Hudson builds for you so that you can monitor them.