Skip to main content

Module Suite building tips (part 4)

Posted by richunger on December 21, 2005 at 2:42 PM PST

Today, I'll be taking the stock Module Suite build files, and creating a nightly build process.
My process does an update on the source tree, builds it, runs unit tests, publishes the result to
our intranet, and labels the source tree.

My particular project uses ClearCase as the source control repository, though this should be simple
enough to tweak for CVS, subversion, perforce, etc.

All these targets are just in my root build.xml.

To start, here's a high level overview of the tasks which need to be completed:

<target name="nightly-impl">
    <antcall target="clean"/>
    <antcall target="repository-update"/>
    <antcall target="build-zip"/>
    <antcall target="test-all"/>
    <antcall target="publish-build"/>
    <antcall target="label-build"/>

The 'clean' target is just inherited. 'repository-update' looks like this:

<target name="repository-update">
    <ccupdate viewpath="."

...though, of course, that's clearcase-specific.

The 'build-zip' and 'test-all' targets are inherited as well, though I override 'build-zip' as seen in my previous entry.

Publishing to the intranet, in my case, is just a simple copy with a fancy naming scheme. The variables ${vb.release.location} and ${} must be defined elsewhere.

<target name="publish-build">
        <format property="buildnumber" pattern="yyMMdd" timezone="UTC"/>
    <property name="nightly-release-dir" value="${vb.release.location}/nightly"/>
    <mkdir dir="${nightly-release-dir}"/>
    <copy file="dist/${}.zip"
          tofile="${nightly-release-dir}/V-Builder-${}-${buildnumber}.zip" overwrite="yes"/>

Labelling/tagging the build is, once again, a clearcase-specific thing. The syntax for CVS, etc. would be different:

<target name="label-build">
        <format property="buildnumber" pattern="yyMMdd" timezone="UTC"/>

    <property name="label-ver" value="REL-${}-${buildnumber}"/>
    <ccmklbtype typename="${label-ver}"/>
    <ccmklabel viewpath="."

The last step is to provide some kind of notification/logging of the status of the nightly build. I do this by invoking ant with command-line parameters for sending the console output to some email address:

<target name="nightly">
    <exec executable="cmd" failonerror="true">
        <arg line="/c ant -logger -DMailLogger.from=${}${}${} -DMailLogger.mailhost=${} nightly-impl"/>

Then we just set up a cron job that runs "ant nightly" at the top of the source tree. Simple, eh?