Hudson is a tremendously popular open source Continuous Integration tool mainly used for Java based projects. There is evidence that the Delphi community is picking up Hudson as a build tool as well (Hudson is built in Java) and even rumblings about Embarcadero themselves using Hudson to build Delphi.
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:
echo Building My Delphi Project call "C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\bin\rsvars.bat" msbuild /p:Win32LibraryPath="$(BDS)\lib;$(BDSUSERDIR)\Imports;$(BDS)\Imports;$(BDSCOMMONDIR)\Dcp;$(BDS)\include;" /t:build /p:config=Debug /verbosity:detailed "MyDelphiProject.dproj" if errorlevel 1 exit 1
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!
[…] https://christerblog.wordpress.com/2010/04/25/using-hudson-to-build-delphi-projects/ […]
[…] Fahlgren has also written a very nice blog post about running Hudson on Delphi projects.Share or Bookmark this […]
If you want the code i dont mind sharing it. You can get in contact with me at hudson@sharken.dk
Hi guys!
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.
Thanks!!!
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.
[…] as people start using Hudson to build Delphi I know that people (at least I do) desire the same level of quality introspection and visibility in […]
I have created a testrunner for DUnit, that will generate output compatible with Hudson.
Have tried to contact the DUnit people so they can integrate the code into their project. So hopefully it will show up sooner or later.
Bo, that is great. Please keep me posted on the progress!
We are starting to use Hudson and DUnit2 to test our applications. I’m very interested in the testrunner you created. Is there any chance that you could send it to me?
Thanks for the great article. It helped me getting started with Hudson.
I would like to know how to integrate DUnit into Hudson? Do you have it integrated in your Hudson server?
Greetings from Germany
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 guess I should have read the entry closer. All i needed to do was include the Win32LibraryPath.
If you are moving to Delphi XE (2011), please note that “Win32LibraryPath” is now called “DelphiWin32LibraryPath”.
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
Here is a link to the podcast:
http://www.delphi.org/2010/05/40-nick-hodges-part-1/