Recently I have read an article about continuous integration with Hudson in “entwickler magazin” 1.2011. But this article was about Hudson and PHP only.
I was wondering, if there is any possibility to use Hudson for my Delphi projects. Indeed, the Delphi developers themselves are actually using this build system.
Here are some links:
- http://christerblog.wordpress.com/2010/04/25/using-hudson-to-build-delphi-projects/
- http://blogs.embarcadero.com/nickhodges/2010/03/10/39369
- http://hudson-ci.org/
I had put off the implementation of an automatic build system a long time. Now, I decided to implement such a system in my days off between christmas and the new year.
Here is a small how to:
1. VMWare Setup
Create a virtual machine. My favorite is VMWare Workstation.
For optimum performance you should set the disk capacity of the virtual disk to a fixed value.
If you want save backups of this vm under FAT32 systems, you should split the virtual disk into pieces of 2 GB.
In my case I am using Windows XP with 50 GB fixed disk space in one single file.
2. Windows Installation and updates
Install operating system
Windows installation
After installing OS I do always a snapshot of the actual virtual machine state. With this snapshot you can revert to a clean operating system in case of problems.
Install VMWare tools
Install all service packs and updates of the used operating system
Activate operating system
3. Software installation
- first step: install VMWare tools
- Install an anti virus software. I will give Microsoft Security Essentials a chance: http://www.microsoft.com/germany/protect/products/computer/mse.mspx
- Download and install a web browser of your choice or use Microsoft Internet Explorer. My favorite is Firefox: http://www.mozilla.com/de/firefox/?from=getfirefox
- Download and install a Java runtime environment, for instance JRE 1.5 from http://www.java.com/de/download/
- Download and install .NET 2.0 from http://www.microsoft.com/downloads/details.aspx?displaylang=de&FamilyID=0856eacb-4362-4b0d-8edd-aab15c5e04f5
- Download and install a subversion client, my favorite one is TortoiseSVN, url: http://tortoisesvn.net/downloads.html
- Download and install Inno Setup 5, url: http://www.jrsoftware.org/isdl.php#stable
- Download hudson from http://hudson-ci.org/latest/hudson.war
4. Delphi
You can install a run a full Delphi installation.
Or you can copy some files from your original system to the build system:
Original “C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\bin” –> to build vm “C:\Continuous Integration\Delphi\bin”
Original “C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\lib” –> to build vm “C:\Continuous Integration\Delphi\lib”
Original “C:\Program Files (x86)\Embarcadero\RAD Studio\7.0\Imports” –> to build vm “C:\Continuous Integration\Delphi\Imports”
5. Hudson first start
Hint: you must have installed Java.
Create a batch file named “start hudson.cmd” with the following content:
Run this batch file.
The other way is to run this command from the command line.
Open the following url in your web browser: http://localhost:8080/ and you can see the Hudson dashboard:
6. Hudson setup
Name of Hudson
First we want to change the name of Hudson – therefore click “Manage Hudson” and than click on “Configure System”. In the bottom change the “Hudson url” from http://localhost:8080/ to http://whatyouwant:8080/ and save the changes.
Install Hudson as a service
Hint: you must have installed .NET 2.0 for the Windows service installation.
In the Dashboard, click “Manage Hudson” and than click “Install as Windows Service”.
Than you have to specify the installation directory:
In my case I changed the installation directory to “C:\Continuous Integration\Hudson”.
Click “install” button, wait until the service is installed and than restart Hudson.
Set up e-mail
In the Dashboard, click “Manage Hudson” and than click “Configure System”.
In the area “E-mail Notification” specify your smtp server, the admins e-mail address and if neccessary click on “Advanced” and set up your SMTP Authentification.
Click “Save”.
Create the first job
In the Dashboard click “New Job”.
Specifiy a job name.
Select “Build a free-style software project”.
Click “OK”.
In “Advanced Project Options” you can specifiy a custom workspace. I suggest to use a custom workspace. Don’t doing so, Hudson will create a full copy of your subversion folder in every workspace of each job. Imagine you have many jobs and more than 1 Gigabyte of source code…
My custom workspace is “C:\Continuous Integration\SVN”.
In the “Source Code Management” area we have to select “Subversion”. Specify your “Repository URL” and type in credential if neccessary.
Check “Use update”
Check “Revert”
In area “Build Triggers” check “Poll SCM” and type in
0,5,10,15,20,25,30,35,40,45,50,55 * * * *
to poll the source code management system every 5 minutes.
In area “Build” add a build step. For instance “Execute a Windows batch command and type in “echo test”.
In area “Post-build Actions” check “E-mail Notification”, type in minimum one e-mail address in field “Recipients” and check “Send e-mail for every unstable build”.
Click “Save”.
Run the first job
Click “Build now” to start the first job.
You can see a progressbar on the left side. Click on that progressbar to get detailed information about the actual build state. If everything is fine, Hudson does a SVN update into “C:\Continuous Integration\SVN”.
Waint until the build is finished.
Build Delphi components
You have to configure the job. Go to “Execute Windows batch command”.
In Delphi projects you have to build Delphi components and then your Delphi projects.
So we build the components first.
In my example there is a group project file with all third party components.
@ECHO OFF
echo Delete old share, create a new one, map the share to K:\
NET SHARE "Delphi components" /DELETE
net share "Delphi components"="C:\Continuous Integration\SVN\Delphi components"
net use K: /delete /yes > NUL
START /wait net use K: "\\sfci\Delphi components" /PERSISTENT:NO
echo set up environment variables
SET BDS=C:\Continuous Integration\Delphi
SET Win32LibraryPath=%BDS%\lib;%BDS%\Imports;%BDS%\Lib\Indy10;%BDS%\include;%BDS%\RaveReports\Lib;K:\_Output\DCP;K:\VirtualTrees\VirtualTrees V.4.8.6\Source;
SET APPDATA=C:\Dokumente und Einstellungen\ci\Anwendungsdaten
echo building components
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe /nologo /t:Build /p:config=Release /verbosity:quiet "K:\AllMyComponents_Delphi_2010.groupproj" /p:Win32DCPOutput=K:\_Output\DCP /p:Win32DLLOutputPath=K:\_Output\BPL
Save again und try to build the job.
In Win32LibraryPath you have to specifiy all paths that are in your library path in your Delphi IDE.
Build Delphi projects
Now you can add a second ”Execute Windows batch command” where you build your Delphi project.
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\msbuild.exe /nologo /t:Build /p:config=Release /verbosity:quiet "C:\Continuous Integration\SVN\AllMyDelphiProjects.groupproj"
Run Inno Setup
After building your Software you can run a setup creation tool of your choice.
Here is an example of calling Inno Setup from command line:







