I started using Hudson about a year ago in my day job as a step in organizing the build process for a bunch of Java projects that didn’t have an automated build and I have found it to be a tremendous help, not only in coordinating a team effort but also on a personal software process level, i.e. even if you are a single programmer on a project, I can guarantee you that you will see the benefit of using a CI tool like Hudson.

As I was getting totally smitten by Hudson in my day job, my hobby project in Delphi was suffering. Even though I was using Subversion and had automated build scripts and being a single developer I still found (my own) release process to be ad-hoc and brittle. So, enter Hudson to build my Delphi project as well. Since I am hoping that increased usage of Hudson in the Delphi community might lead to some new cool Delphi specific plugins from the Delphi community, I decided to write this little introduction.

Building a Delphi project using Hudson

Are there any prerequisites to start using Hudson? Virtually none – as you will see later on in this post, if you can write a few lines of batch script you are good to go. Well, maybe we should say that it is a pre-requisite to use one of the supported source code management systems(SCM). If your SCM is not supported, chances are you should switch (yes, it cannot be a popular SCM you are using…).

The first step is installing Hudson on a machine (if you have no other machine, your development machine will work fine). We shall not spend any words describing that since installing Hudson is so easy it should be set as an example for other systems!

The second step is to create what is called a job in Hudson parlance. A job can be described as the “build project” that describes all the aspects of building something. You will want to choose ” Build a free-style software project”

The third step is to link the job to your Source Code Management system. Out of the box, CVS and Subversion are supported, for all others, you need to first install the appropriate SCM plugin. Hudson will place all the files from the SCM in to a “Workspace” in the filesystem from where the project is built.

The fourth step is to add a build step. Select “Execute Windows Batch Command” in the drop down box. If you haven’t already created a batch file that can build your project, now is the time. Delphi is using MSBuild, which makes it quite easy to create such a batch file. Chances are it will be this simple:

Test your batch script from the command line. If it works, you are ready to call this batch file from Hudson. Remember to check it in so that Hudson can fetch it from the SCM!

Now press SAVE on the bottom of the page.

Now you are ready to build your project. Select “Build now” and see if you get a blue dot for your project. If you get a red dot, go to the console output for that build to find out what happened.

So what have we done so far? We have made sure that Hudson can; 1. Fetch the source from the SCM. 2. Build it successfully. Now we need to make sure we live up to the “C” in continuous integration. This is done by configuring the “Build triggers” for the job to poll the SCM for changes. I usually set it up to poll every 15 minutes, but YMMV.

That’s all folks! May you all be successful in using Hudson to build your Delphi projects!

Is there a required version of Delphi to run this integration? I currently use Delphi 7 (yeap, it’s very old…) and I’m having problems to do my builds with command lines. So far, it’s the only way to build Delphi projects with Hudson.

As long as you can create a batch file to compile your project (quite easily done for Delphi 7 too) you can certainly do a Hudson integration. But if you’re having trouble creating a batch file to build your project I wouldn’t recommend trying to do it from Hudson either.

Excellent post. this was exactly what i’ve been looking for for awhile to use with Delphi.

This works great when you run Hudson in Glassfish from the currently logged in user, but any tips to get it all to work as a system service? Seems like i’m having path issues with the compiler when I try to run a build when glassfish is installed as a service using the local system account.

I just Interviewed Nick Hodges (interview will be available shortly) and he mentioned that they use Hudson and talk about how great it is working for him. Allen Bauer mentioned they use it too: http://twitter.com/kylix_rd/status/13624898477