Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Continuous integration with Hudson

Open source CI server offers easy setup and configuration

  • Print
  • Feedback

Page 5 of 7

The JBoss JMX console

Figure 9. The JBoss JMX console

Deploying Hudson is simple and is done by copying the hudson.war file to /home/jboss/jboss/server/default/deploy. This is best done using the jboss user to ensure that the JBoss server has the privileges to read the file. Hudson should deploy in a few seconds, and then you can validate the deployment by pointing your browser to http://localhost:8080/hudson. The page that displays should be the same as the one shown in Figure 8.

Setting up a build in Hudson

You've now stepped through the procedures for installing Hudson in Tomcat running on Windows XP or JBoss running on Ubuntu Linux. Most of these steps involved installing the application servers and performing administrative tasks in the operating system; I think you will agree that the Hudson installation itself was trivial. Next, you will see how to configure some required basics in Hudson so that you can set up a build job.

Prerequisites

Before you set up a build job in Hudson, the following conditions must be met:

  • You must have an accessible source code repository.
  • The repository must contain the source code you want to build.
  • The repository must contain build scripts that will build the source. These are usually Ant or Maven scripts, although Hudson also supports simple shell scripts, NAnt, and MSBuild.

In this article, you will be using Ant version 1.7 to build the example source.

Configuring Hudson

You do need to attend to some minor configuration in Hudson before you can start building software. To begin, you must tell Hudson where your Java JDK and Ant installations are. On the main Hudson page at http://localhost:8080/Hudson, click the Manage Hudson link. On the page that comes up next, click Configure System.

On the system configuration page, note the first item in the list, which is Home directory. This is where Hudson performs all its work and stores all its configuration. I will come back to this directory later in this article.

In order to configure both a JDK and an Ant instance, click the Add button under each section. A set of fields will expand out under the configuration section. These two sections are illustrated in Figure 10.

Configuring Ant and JDK

Figure 10. Configuring Ant and JDK

In each case, you assign an arbitrary name identifying the JDK and Ant installation. You need to assign these because multiple instances can be configured, depending on the needs of your project; for instance, you might have Java JDK instances for 1.4, 1.6, and 1.7, as well as Ant 1.6 and 1.7. When you configure your project build, you will select the instance you want to use. Note that Hudson immediately notifies you that the blank fields representing JAVA_HOME and ANT_HOME are not valid directories. When a valid directory is entered, these warning will go away. This is a simple example of Hudson's user-friendliness: it gives you immediate feedback rather than waiting for an error to occur when the directory cannot be found.

Because I already installed a Java 1.6 JDK, I can configure the JDK installation as follows:

  • Print
  • Feedback

Resources

Downloads

  • Get the latest Hudson WAR file here or here.
  • Download apache-tomcat-6.0.18.exe to install Tomcat on your Windows machine. Download JBoss 4.2.3.GA for a Linux environment (look for the file named jboss-4.2.3.GA.zip).
  • Ant is the build tool used for examples in this article.
  • jboss-init.sh enables the automatic start and stop of the JBoss server.
  • If your Hudson server cannot connect to outside resources, you can download the plugins you need from the Hudson Website.

Learn more

More from JavaWorld