Yesterday was a Continuous Integration day. I am pretty familiar with tools like apache ant and Cruisecontrol. But these tools just don’t cut it. I don’t like the website that you use with cruisecontrol and Maven is becoming more popular every day. Then I read that Luntbuild had a new release. I have been experimenting with Luntbuild in the past and thought about giving it another go.

First I needed to install luntbuild. There is an install guideline for dummies on the wiki. According to the guideline I installed tomcat (version 4.1.31), that is really not to hard. Then you should use the installer for luntbuild (version 1.2), this isn’t working on my windows Xp. There is an issue with the script, uses a jar command that is not working out of the box, probably a hole in my knowledge. Then I downloaded the zipped version, altered the web.xml and applicationContext.xml files. I replaced some placeholders with real values

web.xml – installDir, added the real path to the installation directory of luntbuild
applicationContext.xml – inMemoryAuthenticationDAO, changed the placeholder of the password for luntbuild user

For simplicity I used winzip to create the war file from the luntbuild/web directory. Then go to the tomcat manager website and upload the warfile. Then everything should be working and you should be able to logon to the luntbuild website.

Now what? I have a website then can manage builds. I think I need a build first and to create a build you first need a project. The last few days I have been experimenting with springframework. In order to store the results I created a project at tigris.org, drop me an email if you want to have access to the website. This website uses Subversion as a Repository.

Oke, now I have a project and I need a build that luntbuild can execute. I did have a look at maven, but I feel more confortable with ant. I created the following build.xml file.

<project name=”SpringSample” default=”compile” basedir=”.”>
  <property name=”dir.src” value=”src”/>
  <property name=”dir.build” value=”build” />
  <property name=”dir.dist” value=”dist” />
  <property name=”dir.lib” value=”lib”/>
  <property name=”dir.test” value=”test”/>
  <property name=”build.junitHtmlReportDir” value=”report”/>

  <target name=”prepare” depends=”clean” description=”Create output directories”>
    <mkdir dir=”${dir.build}”/>
    <mkdir dir=”${dir.dist}”/>
    <mkdir dir=”${build.junitHtmlReportDir}”/>
  </target>

  <target name=”clean” description=”Remove all generated files”>
    <delete dir=”${dir.build}”/>
    <delete dir=”${dir.dist}”/>
    <delete dir=”${build.junitHtmlReportDir}”/>
  </target>

  <target name=”compile” depends=”prepare” description=”Compile all source code”>
    <javac srcdir=”${dir.src}” destdir=”${dir.build}”>
      <classpath>
        <fileset dir=”${dir.lib}”>
          <include name=”*.jar”/>
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name=”jar” depends=”compile” description=”Generates the SpringSample.jar in the ‘dist’ directory”>
    <jar jarfile=”${dir.dist}/SpringSample.jar” basedir=”${dir.build}”/>
  </target>

  <target name=”compiletest” description=”Compile all test code”>
    <javac srcdir=”${dir.test}” destdir=”${dir.build}”>
      <classpath>
        <pathelement path=”${dir.build}”/>
        <fileset dir=”${dir.lib}”>
          <include name=”*.jar”/>
        </fileset>
      </classpath>
    </javac>
  </target>

  <target name=”test” depends=”compile,compiletest” description=”Runs all unit tests”>
    <junit printsummary=”on” fork=”false” haltonfailure=”false” failureproperty=”test.failed” showoutput=”true”>
      <classpath>
        <pathelement path=”${dir.build}”/>
        <fileset dir=”${dir.lib}”>
          <include name=”*.jar”/>
        </fileset>
      </classpath>
    <formatter type=”xml” usefile=”true”/>

    <batchtest todir=”${build.junitHtmlReportDir}”>
      <fileset dir=”${dir.test}”>
        <include name=”**/Test*.java”/>
        </fileset>
      </batchtest>
    </junit>

    <junitreport todir=”${build.junitHtmlReportDir}”>
      <fileset dir=”${build.junitHtmlReportDir}”>
        <include name=”TEST-*.xml”/>
      </fileset>
      <report format=”frames” todir=”${junitHtmlReportDir}”/>
    </junitreport>
  </target>
</project>

I am not going to explain it here, there are good resources to find on the web about ant. The hardest part for me to find (oke, it was time to go to bed) was the integration with junit and luntbuild. Things that are hard to find are often easy to do. Luntbuild can provide parameter values to the ant script. One of these parameters defined in the project is : junitHtmlReportDir. This parameter is used in the report tag to copy the results to.
<report format=”frames” todir=”${junitHtmlReportDir}”/>

Luntbuild can be used to send emails with information about the build. Another fine option is to send messages to a jabber account or an msn messenger. To bad I can not get the messenger part to work. Maybe this will go as is should in the next few days.

There is a good manual for luntbuild on theire website.

I like luntbuild, it is fairly easy to use, I do need to do some work on reports like cruisecontrol has though. The user interface is very nice and does what it should.

Continuous Integration and Luntbuild