My eventual enjoyment with Hudson
Posted by doubleA on March 15, 2007
Due to a Windows password change on my login at work, my Continuum build server quit running builds because it could not connect to CVS. I remembered having this be a major problem when I first setup Continuum so I dug up my notes on how I did the initial setup.
Then the horror came back because there are .cvspass files with Cygwin CVS (my preferred option), .cvspass registry entries with CVSNT (the default on Win). Lots of other applications correctly find the cvspass entries, but for some reason Continuum does not. There are lots of mailing group questions about this issue between Windows and Continuum.
After quite a lot of frustration, I decided to switch build servers. I had seen some articles by Matt Raible and others about Hudson and how it worked with Maven. “Cool, let’s give it the quick test” I thought. So over to the Hudson site for a download and quick setup guide.
I chose to setup Hudson inside Tomcat 6.0.10 but there is also an easy way to test Hudson out. Expand the zip download and then run “java -jar hudson.war”. This starts up Hudson using Winstone and all works quite well. This is probably the best way to do a simple test if you are investigating Hudson for the first time. Using Tomcat is almost as easy because you just drop the WAR into the webapps directory and then go to http://localhost:8080/hudson.
Note: If you use the Winstone container, your Hudson app will be located at http://localhost:8080 with no path.
Note: If you are using Tomcat as a service, setup the service to start as a specific user b/c Hudson creates a .hudson dir under the users Windows home directory. This .hudson dir contains all Hudson data files similar to the way Maven uses the .m2 directory under the user’s home dir.
Now we get to the fun part that eventually gets fun for real. Kohsuke Kawaguchi has a blog post about using the Maven 2 integration in Hudson. DON’T FOLLOW THIS BECAUSE THE FEATURE IS IN ALPHA AND I HAD LOTS AND LOTS OF CLASSPATH ISSUES BETWEEN MAVEN AND HUDSON. It took me almost a day of back and forth before I finally found the quick and easy way to use Maven in Hudson. Just take my advice and don’t struggle with the alpha maven2 integration.
Tip of the day:
Here are my condensed steps for success with Hudson.
- Setup JAVA_HOME for your JDK1.5 install
- Setup your .cvspass file using the tool of your choice.
- Startup Hudson
- Click “Manage Hudson”, then “System Configuration”, and configure your JDK, CVS exe, Maven, and email settings. Save the settings
- Click “New Job”
- This is the most important step. Choose “Build a free-style software project”
- Enter all the info for your project. You can enter which maven targets are run, if emails should be sent, if unit tests results should be reported, etc
- Save your project and then click “Build now”
- All is well in the world and your Continuum troubles go away!!
I setup my builds to poll SCM with a schedule of */5 * * * *. This causes a CVS scan every 5 minutes and it’s working fine for my few projects that are configured. Obviously you may want to change the interval, but be sure to use */n * * * * if you want the poll to occur at regular intervals. If you only use 5 * * * *, CVS will be polled at 5 past the hour for every hour.
I really like the unit test report that is generated. With Maven, you would use a string like “MyApp-core/target/surefire-reports/*.xml MyApp-web/target/surefire-reports/*.xml” if you have a parent project with a core and web sub-project. If you don’t have a parent maven project, use “target/surefire-reports/*.xml”. With this setting, Hudson keeps a graphical view of your unit test success and it’s very easy to see when things go wrong.