Developers love Hudson for its ease of configuration. Rather than dealing with XML files, users can configure all Hudson options via a clean web UI. This includes configuring the base system, adding and configuring jobs, and installing plug-ins. Though Hudson actually stores its configuration in XML files, I have never needed to edit any XML manually while configuring Hudson.
To build .NET projects, you will need to get a few Hudson plug-ins. Fortunately, installing plug-ins, like all Hudson configuration, is simple. Follow these steps to get to plug-in configuration:
- Navigate to the Hudson home page.
- Click "Manage Hudson."
- Click "Manage Plug-ins."
You should find yourself at http://localhost:8080/pluginManager/. From here you will see tabs that show plug-in information, including lists of installed and available plug-ins. If your network requires you to download through a proxy server, you should configure the proxy settings under the "Advanced" tab.
Look at the list of available plug-ins under the "Available" tab. Select the checkboxes next to the plug-ins "Google Code," "MSBuild," and "NUnit."
Next, click the Install button at the bottom of the page, and Hudson will download and install your selections. After installing the plug-ins, restart Hudson by terminating the program with a CTRL-C in the command window and reissuing the Hudson command.
When using Hudson's configuration web interface, you'll see help links for all portions of the configuration that appear as blue question marks. These links provide excellent in-line help. If you have questions about a particular configuration, be sure to check the help links first. Follow these steps to get started configuring Hudson:
- Navigate to the Hudson home page.
- Click "Manage Hudson."
- Click "Configure System."
You should now be the URL http://localhost:8080/configure. Note that the Hudson home directory appears at the top of the page next to the label, "Home directory." This is where Hudson will store all configuration and jobs, including the workspace, and the previous build archive.
You will need to set the path to your msbuild.exe under the heading, "MSBuild Builder." The Framework installs in version-specific subdirectories under C:\WINDOWS directory; that's where you'll find msbuild.exe. The example project requires .NET 3.5. Therefore, you can use this path:
You will most likely want to configure the "EMail Notification" section so that you can get emails notifications of failed builds (see Figure 2). After configuring the SMTP server and the System Admin EMail Address, you can use the link provided to send yourself a test email from Hudson.
Click the "Save" button at the bottom of the page to save your configuration.
Building Hello World
Now that you have configured Hudson, you can add your first build. A Hello World project has been setup at Google Code for this purpose. Since the source repository has public read-only access, anyone is welcome to set up a build for this project.
Creating the Base Project Configuration
Navigate to the home page for your Hudson installation at http://localhost:8080 and then click on New Job. Name your project Hello_World, select the "free-style software project" option, and click OK.
At a minimum, you will need to configure the project name, source code repository, build trigger, and build steps to get anything useful. Here are the configurations:
Project Name: Hello_World
Google code website: http://code.google.com/p/helloworlddotnet/
Source Code Management: Google Code
Build Triggers: Poll SCM
* * * * *
The schedule setting tells Hudson to check source control for changes every minute. To reduce the polling interval, see the help link for more instructions.
To add a build step, click "Add build step" in the "Build" section, and then select "Build a Visual Studio project or solution using MSBuild." You can then configure the build file and command arguments as follows:
MsBuild Build File: HelloWorld.sln
Command Line Arguments: /t:Rebuild
Save the configuration, and then press the "Build Now" link in the upper-left to get your first build. Hudson will create a workspace, download the latest source code, and rebuild the project. When the build starts, a new entry will appear in the "Build History" panel on the left-hand side of the browser. You can watch the console output of the build by clicking on the build timestamp link in the "Build History" box, then clicking on "Console Output."
Source Code Integration
Hudson comes with the ability to talk with many source control systems. Some of them, like Subversion and CVS, ship with Hudson. Others, like Team Foundation Server and Git, require a plug-in. With the Google Code plug-in installed, Hudson will provide links through Google’s REST API so that with a couple of clicks, you can navigate from your Hudson build to the Google Code display of the change set for that build. I checked in one change to the repository after I set up the Hello World build for this article, and you can see the link that Hudson provides to Google Code in Figure 3. Following the link takes you to the Google Code website to display the changes as shown in Figure 4.
The "Changes" link appears after Hudson starts detecting changes in the source control. If you want to see Hudson detecting changes, you will need to create a Hudson build for your own project. Once you commit a change to source control for that project, Hudson will start showing you the changes.
Hudson also provides integration with web interfaces for Subversion and CVS repositories including Trac, ViewSVN, FishEye, WebSVN, and others. Once you have configured the repository browser in the project settings, you will see a link similar to the Google Code link mentioned above.
If you look through the output, you will see that the build has created the HelloWorld.exe in the directory:
While it is nice that Hudson built the artifact, it is not especially accessible there. Instead, you should publish the .exe built by Hudson as a build artifact. That way, users can easily download the output of the build and you can more easily move the artifacts through the rest of your deployment process. To publish the .exe as a build artifact, go back into the project configuration for the Hello_World project. Toward the bottom, select the "Archive the Artifacts" check box under the "Post-build Actions" heading. Under, "Files to Archive," enter:
Save the configuration. Press "Build Now" and Hudson will rebuild the project and provide a link to the HelloWorld.exe. You can click on the link and download the .exe now. Note that each build keeps a reference to its published artifacts, and the project page will have links to the artifacts for the last successful build.