Use RadStudio with Jenkins – no plugin


How to create a job for Jenkins Build Server which will build and execute a unit test application written using Delphi, and without using any Jenkins plugin. This should work with minimal alteration for C++ Builder too.


  1. You should already have installed Embarcadero Delphi XE2 or newer onto your build server. (Tested on XE5 but any version since XE2 should work)
  2. You should already have installed Jenkins build server software onto your build server.
  3. You should have some understanding of what Jenkins is and how it works.
  4. Some understanding of how batch files work will help.

Command-line building

In order to build a Delphi project from Jenkins without a plugin, you must be able to build that project from the command-line. Delphi ships with a batch script which will set-up the relevant environment variables to use MsBuild to build a project, and it is usually installed as “Rad Studio Command Prompt” into your windows menu.

Opening the shortcut file in a editor, we can see that it points to the script that we want, in my case “C:\Program Files (x86)\Embarcadero\RAD Studio\12.0\bin\rsvars.bat”  This path will vary depending on your chosen product and version.

Using this information I wrote the following batch script: delphibuild.bat

call “C:\Program Files (x86)\Embarcadero\RAD Studio\12.0\bin\rsvars.bat”
cd %1 
msbuild %2

I placed this script into my Jenkins server jobs directory (because this is the directory that I back-up, you can place it anywhere you wish).

The script requires two parameters:

  • %1 – The path to the project file within the Jenkins workspace.
  • %2 – The name of the project file.

The Jenkins job…

Armed with the above batch file, create a new job in Jenkins using “Build a free-style software project.”

After adding the necessary build steps to fetch your source code from your source repository (presuming you have such a thing), add a step in the job to build your project using “Execute windows batch command.” Insert the following as the command (modify parts as necessary)…

<path to delphibuild.bat>\delphibuild.bat “%WORKSPACE%\<path to project>\” <project name>.dproj

And then, if you wish to execute the project executable (for example, if the project is a unit-test application) add an additional step as follows…

%WORKSPACE%\<path to project>\<project name>.exe -a

Note: In this case “-a” is passed as an option to the project as the option to tell a DUnit test application to execute all tests. You can omit this parameter if this is not a DUnit test application.

Unit Testing.

A DUnit project as it is written by the build-in wizards in Delphi does not return an exit code. An exit code is required by Jenkins to indicate the success or failure status of the executable when run. You’ll need to modify the test application to return an exit code.

This is an example of an altered test application project source:

program test;
  Delphi DUnit Test Project
  This project contains the DUnit test framework and the GUI/Console test runners.
  Add “CONSOLE_TESTRUNNER” to the conditional defines entry in the project options
  to use the console test runner. Otherwise the GUI test runner will be used by



{$R *.RES}

  R: TTestResult;

  R := TextTestRunner.RunRegisteredTests();
  ExitCode := R.ErrorCount + R.FailureCount;

Thanks for reading!


1 thought on “Use RadStudio with Jenkins – no plugin”

Leave a Comment