Continuous Integration with CruiseControl + FlexUnit + XDoclet2

Last year I blogged about XDoclet2 and FlexUnit and Ant . In this entry I am going to look at setting up CruiseControl for continuous integration. I have setup my CruiseControl server on Linux so I will do my best to make sure these instruction also apply to Windows. I also used Perforce as my source control repository so I have included the extra steps that are required to get CruiseControl working with Perforce. CruiseControl supports many other repositories such as Subversion and CVS. Please refer the the CuriseControl configuration reference for more details.

What software do I need?

You will need to download the following software:

If you are using Perforce you will also need the following:

  • Download the Apache Ant binary distribution Don’t use the embedded copy of Ant that comes with CruiseControl as it doesn’t contain the Perforce tasks – I downloaded Apache Ant 1.7.0.
  • Download the Jakarta ORO binary distribution. Jakarta ORO is required by the Perforce Ant tasks – I downloaded Jakarta ORO 2.0.8.
  • Download the Perforce client (p4).

Do I need anything else?

Yes – if you are running this on Linux you will need an X Server installed and you will probably want a virtual frame buffer. These are required by the Flash Player – there is no headless version of the player. If you try and run the Flash Player without these you will probably get the following error:

Can’t connect to X11 window server using ‘:0.0’ as the value of the DISPLAY

The virtual frame buffer will allow the Flash Player to run in a virtual window without the need for a display plugged in to your server. I used XFree86, which provides an X Server and a virtual frame buffer (Xvfb).

How do I install the software?

  • Extract CruiseControl to a suitable location on your local machine.
  • Install your JDK.
  • Create a JAVA_HOME environment variable with the path to your JDK installation.
  • Add $JAVA_HOME/bin (or %JAVA_HOME%\bin on Windows) to your path.
  • Copy FlexAntTasks.jar to <ANT_HOME>\lib, where <ANT_HOME> is the path to your Ant installation. If you are using the version of Ant that comes with CruiseControl you will find it under your CruiseControl instalaltion. The example config at the end of this blog shows how to configure an alternative Ant installation.
  • Install Flash Player 9.
  • Install Flex SDK.

Note: if you are using Linux the FlexUnit Ant task will use the standalone player, please make sure the Flash Player executable (gflashplayer) is on your PATH.

To verify CruiseControl is working start is using or cruisecontrol.bat (start CruiseControl from its home directory) and connect to the console through your browser using http://<your_server>:8080. You should see a test project called connectfour. Stop CruiseControl after you have connected sucessfully.

If you are using Perforce:

  • Extract Apache Ant to a suitable location on your local machine.
  • Extract Jakarta ORO and copy the JAR (e.g. jakarta-oro-2.0.8.jar) to <ANT_HOME>\lib, where <ANT_HOME> is the path to your Ant installation.
  • Make sure the Perforce client executable (p4) is on your PATH.

You will also need to create a client workspace for Perforce, which is used by CruiseControl. You can do this using the P4V tool or on the command line using p4, for example you can do the following on Linux to create a client workspace:

  • mkdir ~/cruisecontrol
  • cd ~/cruisecontrol
  • p4 -p <port> -c <client_workspace> -u <user> -P <password> client

The final command puts you in the editor, which you can just quit.

How do I run CruiseControl?

If you are running on Linux and using Xvfb execute the following commands:

  • export DISPLAY=:1.0
  • /usr/X11R6/bin/Xvfb :1 -screen 0 1280x1024x8 &
  • cd <CC_HOME>, where <CC_HOME> is the parth to your CruiseControl installation.
  • &

If you are on Windows:

  • Open a command prompt.
  • cd <CC_HOME>, where <CC_HOME> is the parth to your CruiseControl installation.
  • cruisecontrol.bat

You can then connect to the console using your browser: http://<your_server>:8080

How do I configure a project?

You must configure your projects in <CC_HOME>\config.xml, where <CC_HOME> is the parth to your CruiseControl installation.

I have provided an example of config.xml , which externalises its configuration parameters to This example uses my FlexUnitExample project.

Note: use the latest version of FlexUnit for Ant as it no longer requires you to create a FlashPlayerTrust configuration file.