Setting up Hudson for small Teams
Our Java project team has only three developers. We liked the idea to have our tests and builds run automatically and to have a central dashboard. However, we didn’t want to invest much time and expected a continuous integration server to be overkill. But as we started to play around with Hudson, we were quite amazed: the system was up in 5 minutes, including builds, tests, and e-mail notification.
Hudson is an open-source continuous integration server and has drawn a lot of attention since it was awarded with Sun’s Duke’s Choice Awards in 2008. It is nowadays used as the standard build and test environment in many popular projects, including the Eclipse IDE.
Our project setup is very simple: We have a few dozen Unit tests, and we use Ant to run the tests and to build the project. Hudson is a very powerful tool, and we expected it to be overkill for our simple setup. However, we started to play around with it, and voilà: The system was up and running in five minutes, including builds, tests, and e-mail notification!
In this first article of our Hudson series we would like to share our experience that:
- Hudson is very easy to start with
- Hudson is worthwhile to use, even in very simple projects
The focus of this article is on a basic Hudson setup. Advanced features, such as Hudson plugins, will be a subject of the next post.
Step 1: You Need a Server
As shown in the figure below, you need a server to run Hudson. We already had access to a server in our network that was used for network testing. As Hudson does not require many system resources, we just installed Hudson there. You could also install Hudson on the server hosting your code repository.
Step 2: Download and Start Hudson
Hudson is available for download as a single WAR-file. However, you do not need to deploy an application server to run Hudson, everything you need is included in the file. Just start it using the command
java -jar hudon.war
That’s it. Point your browser to “http://server:8080″, and you see the Hudson Web interface.
Step 3: Configuration
Hudson is configured via the Web interface. There is no need to fiddle around with XML or config files. The Web interface is quite self-explanatory, and has good embedded online help.
The typical configuration steps are
- Click on “New Job”, then enter a name for the Job and choose “free-style software project” as the job type. This is the standard job type which allows you to choose everything freely.
- Answer some questions such as which source code repository to use (we use Subversion), and which build steps are required (we call Ant targets).
- If you want to receive e-mails from Hudson, click on “Manage Hudson” on the start page, and choose “Configure System”. There, you can input the SMTP server to be used when sending mails.
All of this is very easy. You will have your first build running in 5 minutes.
When we first installed Hudson, we were mainly interested in a central Web site where we can access the current build versions of our software. However, it turned out that we benefitted a lot more from using Hudson, even in our simple scenario:
- Clever notification algorithm: when somebody makes a commits and the Unit test fails, Hudson sends out an email only once. There are no repeated mails for repeated failures, and there are no mails to developers who didn’t contribute to the failure. Therefore, it is easy for developers to pay attention to Hudson mails: almost every mail from Hudson means that a new bug was discovered that has to do with your code.
- Hudson allows for a very short feedback loop. We configured Hudson to check the Source Repository every 30 minutes. That is, if you commit something, integration tests are run on that code not later than 30 minutes after commit. If a build failure is detected, you are notified promptly, and you may fix the failure even before another developer checks out your code.
Plugins: Hudson makes it very easy to install plugins. Once started with Hudson, there’s a lot you can do. There is a list of available plugins on the Hudson Web interface, and you can install these plugins directly from that interface. Browsing this list, we found some very useful plugins, such as the FindBugs plugin.
Over the months, we installed a few of these plugins, and our Hudson now does not only build and test our code, but also help us to improve code quality, and to ease our code review process.
We were very surprised of how easy it is to start with Hudson. And how much you benefit from it, even in small and simple software projects. Hudson helped us to significantly improve our code quality and, by using some plugins, we are now saving a lot of time in our code review process.
However, Hudson is not only easy; it is also a very powerful tool. When your project eventually ends up using different programming languages, and tests need to be run on different operating systems in a test cluster, Hudson will provide support for all this.
For an in-depth introduction to Hudson, we recommend Kohsuke Kawaguchi’s talk at the San Francisco Java User Group.
Leave a Reply
You must be logged in to post a comment.