Hudson – Your Escape from "Integration Hell"
Dr. Simon Wiest, Dr. Wiest Software Engineering, http://www.simonwiest.de
Hudson is a popular web-based continuous integration server, written in Java. Hudson is used in 17.000+ server installations worldwide in small, medium and large companies alike, including eBay, Hewlett-Packard, MySQL, JBoss, Xerox, Yahoo, LinkedIn, or Goldman-Sachs. It allows you to automate your software build chain, e.g. monitoring changes in version control systems, triggering new builds, testing artifacts, sending notifications, deploying to production servers, and much more. Hudson is liked for its ease of use and broad extensibility via 250+ plugins.
Version Tested: Hudson V1.358 (Mai 2010)
License & Pricing: Open Source (MIT License)
Support: User and developer mailing lists
"Continuous Integration (CI) is a software development practice where members of a team integrate their work frequently, usually each person integrates at least daily - leading to multiple integrations per day. Each integration is verified by an automated build (including test) to detect integration errors as quickly as possible. Many teams find that this approach leads to significantly reduced integration problems and allows a team to develop cohesive software more rapidly." (Martin Fowler, http://martinfowler.com/articles/continuousIntegration.html)
Figure 1: A typical continuous integration cycle
Hudson is a CI server that allows you to implement that approach (Figure 1): Developers will check in new code into your version control system (1). Hudson polls this system regularly for changes, e.g. every minute (2). If changes are indicated, the new code is checked out to build severs (3) and a new build of your project is executed. The results are reported back to Hudson (4) that will set the new status of the project (5): stable, instable, or failed. Finally notifications are sent to developers and other stakeholders (6), which will either fix any problems found or proceed implementing new features. This complete cycle typically does not exceed 15 minutes.
Download the latest release from http://hudson-ci.org/latest/hudson.war. Start Hudson in the command line using the following command: java –jar hudson.war. Finally, open http://localhost:8080 in your web browser. You should now see the Hudson Dashboard (like Figure 2, but for obvious reasons without any projects yet). You are now ready to run. If port 8080 is already used, you can choose another port by starting Hudson with a command like: java -jar hudson.war --httpPort=8888. Hudson can also be deployed in application servers like Tomcat, WebSphere or JBoss.
The Hudson project publishes new releases roughly every week. Hudson will inform you of updates available on its Administration page (Hudson / Manage Hudson). Plugins are installed via the built-in Plugin Manager (Hudson / Manage Hudson / Manage Plugins).
Figure 2: A typical Hudson Dashboard
Very useful documentation is placed right into the application as context-sensitive help. There’s also a wiki on the project website and two active mailing lists for users and developers (some 18,000 postings in 2009). Two books on Hudson are currently in progress, "CI with Hudson" by J.F. Smart and "CI mit Hudson" (in German) by S. Wiest.
Building and testing software is a rather resource intensive process. Continuously building software obviously requires even more computing power. Hudson can distribute your builds to a grid of build servers, the "slave nodes". This speeds builds up, but also enables you for example to test software on multiple slave nodes running different operating systems, databases, application servers, web browsers, service packs, etc. Slave nodes can be run on "real hardware" under your desktop, in your data center or on virtualized systems, e.g. on a VMWare host or in the Amazon EC2 cloud. Hudson will take care of monitoring the nodes, distributing the work and collecting the results, once the builds have been completed on the slave nodes.
As software build chains always differ from team to team, a good CI server must demonstrate "infrastructure chameleon" capabilities. Hudson is extensible by 250+ plugins, offering support for alternative build tools (e.g. msbuild, gradle, rake), version control systems (e.g. CVS, Git, Perforce, Mercurial), notification channels (e.g. rich email, jabber, twitter, eXtreme feedback devices), virtualization and cloud computing (VMWare, Amazon EC2), user directories (e.g. LDAP, ActiveDirectory), issue trackers (e.g. JIRA, Bugzilla, Mantis), and much more. At current pace, the Hudson community releases 1–2 new plugins and 3–5 updates of existing ones per week. The source code of these plugins is available to serve as a starting point for own customizations. In fact, many Hudson "heavy users" came for a shrink-wrapped, ready-to-use product, but stayed for a highly customizable build automation platform.
Building a "Test Drive" Project
You understand Hudson best by seeing it in live action. Thus, for a simple five-step test drive of Hudson, you could build any Open Source project that hosts its source code publicly accessible. We will use Apache Commons IO in the following example:
- First go to Hudsonŕ Manage Hudsonŕ Configure System: In Section "JDK" add a new Java Development Kit. In section "Maven" add a new Maven installation. Click on "Save" at the bottom of the page.
- Then go to Hudsonŕ New Job enter "apache-commons-io" as job name and choose "Build a maven2 project". Click on "OK" to proceed with the job configuration page.
- On the job configuration page, in section "Source Code Management", choose "Subversion" and enter "http://svn.apache.org/repos/asf/commons/proper/io/trunk" in field "Repository URL". Click on "Save" at the bottom of the page.
- Click on the "Build Now" icon in the left sidebar. A new build will start, checking out the source code, then compiling and testing it. You can follow the progress by peeking at the live output of the build: Click on the progress bar on the left hand side to open the console view.
- Once the build has been finished, return to the Hudson dashboard page by clicking on "Hudson" in the top left corner. If the build succeeded, you will see a blue ball icon. If any problem occurred, the ball will be yellow or even red. Note how you can browse the test results interactively by clicking on the project name and then on "Latest Test Results".
You have now configured your Hudson server, added your first job and built it. In a production instance, builds would be triggered automatically (by changes in the version control system or by a timer) — but the basic scheme would be the same.
Continuous Integration is a software development practice that most teams cannot think of living without, once it has been established. With Hudson, the necessary tooling is fast to install, easy to maintain and scalable for future extensions.
A final note: While Hudson is implemented in Java and supports mainstream Java build chains out of the box (CVS/Subversion, Ant/Maven, JUnit/TestNG), it is not restricted to the Java world: Many companies use Hudson to automate their software development efforts in C/C++, C#, PHP, Groovy, Scala, and many other languages.
More Continuous Integration and Agile Content