Skip to content

Building and Testing with CruiseControl_9241965

nxi edited this page Apr 9, 2015 · 1 revision

Table of Contents

Gumtree : Building and Testing with CruiseControl

Created by Tony Lam, last modified on Aug 27, 2007

Introduction 

This article discuss how to achieve continuous integration (CI) and automated testing for GumTree Project via CruiseControl.  In this example, we will use the standard template that is used to build all GumTree artifacts within ANSTO.  You may study the template and reconfigure to build customised GumTree for your facility.

Setup

Requirements

  • Windows XP
  • JDK 6.0 or above
  • Network connection the codehaus SVN repository

Software to be installed

  • CruiseControl 2.7 download
  • ANT 1.7 download
  • Eclipse SDK 3.3 download
  • IDE Tools (optional -- only if you use Eclipse IDE as the subversion client to checkout the cruisecontrol template from SVN)
    • Subversive
  • RCP plugins (similar to want you need to build GumTree from Eclipse IDE)
    • EMF, SWTplus, EclipseMonkey, SWT OpenGL, etc

Recommended Directory Structure

D:\ (or any windows drive)
+- gumtreebuild (contains anything for building and testing)
    +-app (applications for sequencing building and testing)
        +-apache-ant-1.7.0
        +-cruisecontrol-bin-2.7
            +-...
            +-projects
                +-gumtree (folder for building and testing GumTree)
                    +-config
                    +-source
                +-...
    +-dev (Eclipse stuff; similar structure as for your normal development environment)
        +-ide (IDE for checking out template)
            +-eclipse3.3
                +-eclipse
        +-target (All required Eclipse components for building GumTree RCP)
            +-eclipse3.3
                +-eclipse
        +-workspace (workspace for checked template)

Step 1: Eclipse

Setup Eclipse as what you normally do for your development environment (see committer setup from this page for details)
  • Install Eclipse IDE to D:\gumtreebuild\dev\ide with subversive
  • Install Eclipse RCP target to D:\gumtreebuild\dev\target with required RCP plugins
Checkout the CruiseControl template from Codehaus The CruiseControl contains the following materials:
  •  config.xml
    • The customised CruiseControl config file that calls ANT 1.7 to build GumTree.  It also merges the test results and publishes final artifacts to the archive folder
  • gumtree folder
    • This folder contains build and test configuration for each GumTree RCP distribution.

Step 2: CruiseControl

  • Extract CruiseControl to D:\gumtreebuild\app\cruisecontrol-bin-2.7
  • Set JAVA_HOME to your JDK6 directory (required by the Jetty server)
  • Set webport in cruisecontrol.bat to 6060 (if another service has used the 8080 port)
  • Uncomment CC_OPTS in cruisecontrol.bat for more heap memory

Step 3: ANT 

  • Extract ANT 1.7 to D:\gumtreebuild\app\apache-ant-1.7.0
  • Extract all SvnAnt lib files to D:\gumtreebuild\app\apache-ant-1.7.0\lib

Step 4: Use the GumTree NBI CruiseControl Template

  • Remove the existing CruiseControl example in D:\gumtreebuild\app\cruisecontrol-bin-2.7\projects
  • Copy the gumtree folder in the CruiseControl template "cruisecontrol.nbip" (as previously checked out from Codehaus SVN) to D:\gumtreebuild\app\cruisecontrol-bin-2.7\projects
  • Replace config.xml in the CruiseControl template "cruisecontrol.nbip" to D:\gumtreebuild\app\cruisecontrol-bin-2.7
[Important] Since the initialise GumTree CruiseControl project folder DOES NOT contain any GumTree source for build, we need to reconfigure the build setting to fetch sources
  • Edit the build properties file D:\gumtreebuild\app\cruisecontrol-bin-2.7\projects\gumtree\build.properties
  • Unmask #sourceCheckout=true to sourceCheckout=true
Now, we can launch CruiseControl  from cruisecontrol.bat.  Initially it will automatically schedule a build during this first launch.  Build may fail if you are behind the firewall.  To enable proxy for SvnAnt, you need to edit the file "servers" in your local subversion setting. Type http://localhost:6060 in your browser to check the current build status

Step 5: Install and run JMX scheduler

Build can be scheduled using JMX call (via HTTP).  The default CruiseControl scheduler does not seem to work because we are building multiple builds within a CruiseControl project.  In order to use our own JMX scheduler, check out the cruisecontrol.nbip.scheduler project from Codehaus SVN. Export the project into a jar file (use the existing manifest.mf for your jar), and also copy all jar libraries into the folder D:\gumtreebuild\app\scheduler.  Run scheduler.bat to start the scheduler.

Configuration 

Add or remove additional plugins from the source checkout list

The source checkout list is located under the gumtree folder, called "project.txt".  Each entry in this text file represent individual checkout from the SVN repository.  The format of an entry follows: <feature or plugin>, <project name>, <SVN URL with login details> Examples:
  • feature, org.gumtree.platform-feature, https://[email protected]/gumtree/platform/trunk/org.gumtree.platform-feature
This checks out the feature project "org.gumtree.platform-feature" into the feature directory This checks out the plugin project "org.gumtree.ui" into the plugin directory

Skip source update (eg when SVN connection is unavailable)

Uncomment (remove #) the following line in the gumtree build.properties file: #skipSourceUpdate=true

Enable complete clean and source checkout

Uncomment (remove #) the following line in the gumtree build.properties file: #sourceCheckout=true

Skip individual product build and testing

Uncomment (remove #) the following line in the gumtree build.properties file: 
  1. isee.skipBuild=true
Removing # on above line will skip both build and testing on the ISEE project.  To skip testing only, comment above line, but uncomment the following: #isee.skipTest=true

Change program command line arguments for application testing

Edit "eclipse.ini" in the individual build config folder

Modify or schedule additional build on JMX scheduler

Build scheduling using the JMX scheduler is done on hourly based.  By default, it runs on 12pm and 8pm daily.  You can reconfigure the hour (24 hour format) by editing scheduler.properties.

How thinks work? 

The build process involves the following sequence:
  1. Source check out / update
  2. Product build and packaging
  3. Product testing
  4. Merging test results into build log
  5. Publish exported artifacts to archive folder

Source check out / update

All feature and plugin projects needs to be checked out or updated from the SVN repository before build start.  Those SVN operation is controlled by the gumtree build script ../gumtree/build.xml using SvnAnt.  Firstly, it looks for a file called "projects.txt" to get the idea of how many projects are needed for build.  We recommend anonymous SVN access so sources are always be kept as read-only. By default, the gumtree build script is configured to update sources, rather than checking out fresh copy.  If you are building GumTree for the first time, or you need a refresh copy of sources from SVN for some reasons, you should reconfigure the script for doing SVN checkout instead of update.

Product build and packaging

The RCP product build is done by calling the headless PDE product build script from the Eclipse IDE.  It reads the specified .product file for full RCP build, and packages into zip files at the end of RCP export.  You can configure the script to build on multiple OS version.  At the end of the build, those zip files will be renamed with timestamp.

Product testing

Before the build cycle ends, the main gumtree script will call another ANT script to perform automated testing via command line.

Merging test results into build log

At the end of testing, the html test result files and an aggregated XML test result file will be copied to another folders.  The html files are included the export folder, and the XML file is merged into the CruiseControl build log so it can be parsed and displayed in the web application.

Publish exported artifacts to archive folder

All export files (zip files) and html test results will get copied into an archive folder.  This folder is accessible by the CruiseControl webapp when build is completed successfully.

Reference

Document generated by Confluence on Apr 01, 2015 00:11
Clone this wiki locally