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"/>
</target>

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

<target name="repository-update">
    <ccupdate viewpath="."
    graphical="false"
    log="build/clearcase.log"
    overwrite="true"
    currenttime="true"
    rename="false"/>
</target>

...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 ${vb.branch.name} must be defined elsewhere.

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

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

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


    <property name="label-ver" value="REL-${vb.branch.name}-${buildnumber}"/>
    <ccmklbtype typename="${label-ver}"/>
    <ccmklabel viewpath="."
    recurse="true"
    typename="${label-ver}"
    failonerr="false"/>
</target>

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 org.apache.tools.ant.listener.MailLogger -DMailLogger.from=${vb.nightly.email.from} -DMailLogger.failure.to=${vb.nightly.email.to.failure} -DMailLogger.success.to=${vb.nightly.email.to.success} -DMailLogger.mailhost=${vb.nightly.email.mailhost} nightly-impl"/>
    </exec>
</target>

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