Skip to main content

Hudson became self-executable

Posted by kohsuke on February 11, 2007 at 11:54 AM PST

Hudson has always been distributed as a single war file, and the installation was as easy as dropping this war to your web container. I thought this was easy enough, but then people pointed out that installing a web container is not all that easy. There has been some discussion about this in the users list, and usual options like bundling Jetty was mentioned, but none of them seemed quite right.

So this has been in the back of my brain for a while, and then the whole thing "clicked" when I saw an e-mail from one of the Hudson users, where he mentioned a recent blog by Tim Shadel.

Apparently there's this servlet implementation called Winstone, which is pretty handy for the embedded use. The whole implementation is in a single jar. So the "3 minute set up of Hudson" that Tim talks about consists of the following 5 steps:

  1. Download winstone from it's Sourceforge Files page
  2. Download the Hudson war file from its Java.net Release page
  3. Then run java -jar winstone-0.9.6.jar --warfile=hudson.war --httpPort=8081
  4. You should see something like the screenshot below.
  5. Play.

But then I thought, since a war file and a jar file are of the same format, wouldn't it be nice if I put a little bootstrap code in hudson.war, so that you can just execute it like java -jar hudson.war?

hudson.war is already a little more than 10MB, so I could easily afford to put winstone.jar in it, which is around 320KB. When you run java -jar hudson.war, a little Main.class in it will take the control, and it uses winstone.jar inside hudson.war to launch itself.

Of course it's still a war file, so you could still just drop hudson.war in any existing web container, and that works, too. With that, the new "2 minute setup" of Hudson becomes the following:

  1. Download the Hudson war file from its Java.net Release page
  2. Then run java -jar hudson.war
  3. You should see something like the screenshot below.
  4. Play.

... except that as of this writing, this new change is still not released yet. So this will work starting upcoming 1.81.

Really, the installation can't get any easier than that.

Related Topics >>