RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Hudson Continuous Integration Server : Page 3

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 plug-ins available to .NET projects, Hudson provides plenty of powerful features.


Running Unit Tests

At this point, you should have a successful (blue) build for the Hello World project. However, Hudson is not running unit tests. To get more confidence in your build, you should run the unit tests with each build. The Hello World project comes with a unit test project including a single NUnit test. The NUnit plug-in for Hudson will reformat the NUnit output, but it will not execute the NUnit tests. To execute the test, you need to set up a batch process that uses the NUnit console runner.

Go back to the project configuration for the Hello_World project, scroll down to the build steps, and add a build step of type, "Execute Windows batch command." Assuming you have installed NUnit 2.4.8 in the default location, your batch command should look like:

"C:\Program Files\NUnit 2.4.8\bin\
nunit-console.exe" HelloWorldTests\bin\Debug\
HelloWorldTests.dll /xml=nunit-output.xml

The first line of the script executes the nunit-console.exe and runs all tests found in HelloWorldTests.dll, placing the results in nunit-output.xml. The second line of the script tells the batch script to bubble out the error level of the NUnit run. This bubbled out error level will cause the build to fail if any tests fail.

Figure 5. Example Project: The example project showing the test trend, published artifact, and build history.

To publish the test results, select "Publish NUnit test result report," and enter the name of the file that you told NUnit to generate, nunit-output.xml.

Save the configuration and then force another build of the project. After the build completes, navigate to the project page at:


You should now see a link to the "Latest Test Result." You can see the final screenshot of the project page in Figure 5. Note that the link given on the project page will always point to the latest published test results. If you want to send out a link to the test results from a specific build, simply navigate to the page for that build and the "Test Result" link from the build’s page will specifically reference the results from that build number.

Installing Hudson as a Windows Service

Now that you have a build setup, you will probably want to install Hudson so that it runs as a Windows service. Assuming your trial Hudson is still running, click on "Manage Hudson" on the Hudson home page, and then "Install as Windows Service." Hudson will verify that you want to keep the same working directory and then install itself as a Windows service. After the installation, Hudson will prompt you to restart.

If you were running or want to run Hudson on a port other than 8080, you will have to make one small change to the hudson.xml file. Open the HUDSON_HOME\hudson.xml file with WordPad or some other editor that understands Unix-style line endings. Find the <arguments> block toward the bottom of the file and change the value assigned to the httpPort argument. After saving the configuration file, restart the Windows service and Hudson should start up on the port that you have assigned to it.


You should now have a passing build that is monitoring source control for changes, running unit tests, and publishing the results. (For more information on monitoring Hudson, see the sidebar Monitoring Hudson with CCTray.) You will find many additional useful plug-ins for Hudson as you go along. The "More Plug-ins" sidebar lists some of the more popular and relevant plug-ins for .NET projects.

Be sure to check out the Hudson home page as well as the Hudson wiki and Hudson mailing lists. I love using Hudson, and if you give it a shot, you may too.

Further Reading and Resources

The Hudson home page is a great place to get started. There, you will find links to everything from getting started to writing your own plug-ins. The Hudson wiki also has recent news links for Hudson. You can find links to the Hudson mailing lists from either the Hudson home page or the wiki. I have found the users’ mailing list to be both active and helpful. Finally, the project owner for Hudson is Kohsuke Kawaguchi, who frequently writes about Hudson. You may find these links useful.

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 http://www.testinfected.net.
Email AuthorEmail Author
Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date