February 10, 2006 - Template Projects with CruiseControl 2.4

At the end of January CruiseControl 2.4 was released. Among all the new features and bug fixes one of the most interesting to me is the idea of using plugin preconfiguration to create template projects. By coincidence over the last few weeks Kevin has been doing major surgery on our build system to make everything more standardized and logical, so it turned out to be a good time for us to try out this template project idea of ourselves.

In our new world build system there are three dependencies every project has: the build system, our common module, and itself. Thus we preconfigure those shared sourcecontrol elements like so:

  <plugin name="my.changes"
          classname="net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem"
          cvsroot=":pserver:builder@cvs:/home/cvsmgr/CVSROOT"
          module="${project.name}"/>

  <plugin name="common.changes"
          classname="net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem"
          cvsroot=":pserver:builder@cvs:/home/cvsmgr/CVSROOT"
          module="com.agitar.common"/>

  <plugin name="build.changes"
          classname="net.sourceforge.cruisecontrol.sourcecontrols.ConcurrentVersionsSystem"
          cvsroot=":pserver:builder@cvs:/home/cvsmgr/CVSROOT"
          module="build.system"/>

With these preconfigured the standard modification set element becomes:

    <modificationset>
      <build.changes/>
      <my.changes/>
      <common.changes/>
    </modificationset>

I like this for the same reason I like I like good names for fields and methods.

After doing a similar preconfiguration of the html email publisher -- and because we've done the hard work to make our build.xml files standard from project to project -- we're able to make our template project:


  <plugin name="project">
    <listeners>
      <currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
    </listeners>

    <bootstrappers>
      <cvsbootstrapper localWorkingCopy="../projects/${project.name}/" file="module-build.xml"/>
      <cvsbootstrapper localWorkingCopy="../projects/build.system/common/" file="module.xml"/>
      <cvsbootstrapper localWorkingCopy="../projects/build.system/common/" file="common.xml"/>
    </bootstrappers>

    <modificationset>
      <build.changes/>
      <my.changes/>
      <common.changes/>
    </modificationset>

    <schedule>
      <ant anthome="../apache-ant-1.6.5"
           antworkingdir="../projects/${project.name}"
           buildfile="module-build.xml"
           uselogger="true"
           target="cc"/>
    </schedule>

    <log>
      <merge dir="../projects/${project.name}/output/test/results"/>
    </log>

    <publishers>
      <htmlemail/>
    </publishers>
  </plugin>

..and then defining our projects is trivial:

  <project name="com.agitar.agitator"/>
  <project name="com.agitar.eclipse.core"/>
  <project name="com.agitar.coverage"/>
  ...

I think that's pretty slick.


Posted by Jeffrey Fredrick at February 10, 2006 04:05 PM


Trackback Pings

TrackBack URL for this entry:
http://www.developertesting.com/mt/mt-tb.cgi/189

Listed below are links to weblogs that reference Template Projects with CruiseControl 2.4:

» Sharing Pre-configuration from Developer Testing
After I posted my blog entry on Template Projects with CruiseControl 2.4 Greg Gipson asked an interesting question about sharing pre-configuration information across multiple CruiseControl servers that turns out to have an elegant answer (if XML Entiti... [Read More]

Tracked on February 16, 2006 03:41 PM


Comments

Hi Jeffrey, I am happy that you like the feature (which I think was already there in 2.3.1)!

Another nice usage is the ability to rename the plugin. Useful if you have different project types, e.g. if you are in the middle of a migration, or if you have 2 different project groups but consolidate the CI on one server.

E.g.

<plugin name="antproject">
... project with ant builder(s) ...
</plugin>
<plugin name="mavenproject">
... project with maven builder(s) ...
</plugin>

<antproject name="ant1" />
<antproject name="ant2" />
<mavenproject name="maven1" />
<mavenproject name="maven2" />
...

You could do the same for cvs/svn, etc...

The URL to the official documentation:
http://cruisecontrol.sourceforge.net/main/plugins.html#preconfiguration

(PS: not sure if this comment will show up correctly, the preview doesn't...)

Posted by: Jerome Lacoste on February 11, 2006 12:13 AM

Hi Jerome!

(for those who don't know Jerome is the person who wrote the patch to allow preconfiguration of project elements.)

looking at the release notes 2.3.1 had preconfigure log elements and preconfiguration of log elements was added in 2.4.

I agree, I really like the ability to create meaningful names using the preconfiguration. Can make the config file much more readable.

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on February 11, 2006 07:18 AM

Oh yeah, and to make your comment display correctly I had to replace your angle brackets (< & >) with entities. (the pre tag isn't the same as the old verbose tag.)

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on February 11, 2006 07:20 AM

You're right for the 2.4, it was checked in 2-3 weeks after 2.3.1 was released.

With regard to preview, I had tried several formats, including with entities, but the preview still destroyed formatting. Anyway, each blog system has its own set of oddities...

Posted by: Jerome Lacoste on February 11, 2006 10:14 AM

Hello,

I am working on an open-source-project based on an eclipse-rcp.

I have already read the tutorial (http://www.eclipse.org/articles/Article-PDE-Automation/automation.html), but I still got some problems.

I could manage to install CruiseControl on our server and integrating in our web container...
...but, my main target is to have automated plug-in builds including building and packaging rcp-applications outside eclipse by using CruiseControl.

However I am far away from the main target:…isn’t there a tutorial/guide which covers this topic referring to eclipse 3.1?

What is necessary to let the build fail if a JUnit Plugin Test is not successful?

Definition of JUnitPluginTests: These are test cases contained in a plugin that test another plugin. Plugin tests have to be run inside an Eclipse workbench (if they need UI) or an Eclipse workspace (when the require no UI functionality).
(see http://www.testdriven.com/modules/mylinks/singlelink.php?cid=4&lid=186)

Bye, Amro.

Posted by: Amro [TypeKey Profile Page] on February 13, 2006 08:24 AM

I don't know of another guide other than the one you mention, though it I didn't follow it much when I put one of our plug-in builds under CC. Across our various modules we either have or have had eclipse plug-ins being built with all manner of approaches: using the eclipse generated build files, using templated versions of their build files, using handcrafted build files, building using eclipse and building w/out using eclipse... on way or another we've managed to make all these work.

But they key in all cases is to get the build working as you like it outside of eclipse before trying to automated it.

Wrt failing when a JUnit Plugin test fails I'm not really sure what that takes. Perhaps it requires post processing of the result files?

If you haven't done so you might try asking your questions on the CC-User mailing list to see how other people have approached these problems:

http://cruisecontrol.sourceforge.net/contact.html

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on February 14, 2006 12:16 AM

Hi Jeffrey,

I didn't realise it was possible to use plugin pre-configuration to create project templates in the way you show here. This is very cool! :)

Patrick

Posted by: Patrick Myles on February 16, 2006 06:59 AM

Yes, this is a really nice feature!

And perhaps this is an obvious comment... But to create similiar plugins like "BldProject" and "TestProject" that are templates for "project", one must use the classname attribute and must know that it's value should be net.sourceforge.cruisecontrol.ProjectConfig.

Posted by: Greg on February 17, 2006 03:32 AM

(could sombody please replace my \n with the linefeed tag or use kinda "pre"?)
I needed a second parameter for my project templates besides the name, so I used a template like this:\n

<plugin name="MyProject"
    classname="net.sourceforge.cruisecontrol.ProjectConfig">
    ....
    <schedule>
        <ant ... target="${parameter.1}_xyz"/>
    </schedule>
    <publishers>
        <artifactspublisher>
        <email>
            <always address="${parameter.2}"/>
        </email>
        </artifactspublisher>
    </publishers>
</plugin>

<MyProject name="p1">
    <property name="parameter.1" value="p1.bla"/>
    <property name="parameter.2" value="me@here.com"/>
</MyProject>

<MyProject name="p2">
    <property name="parameter.1" value="different"/>
    <property name="parameter.2" value="you@there.com"/>
</MyProject>

Posted by: Wolfram Kroll [TypeKey Profile Page] on March 16, 2006 03:52 AM

worlfram, I've fixed up your comment using non-breaking space entities. (the software already converts return to line breaks in comments apparently.)

Posted by: Jeffrey Fredrick [TypeKey Profile Page] on March 16, 2006 07:32 AM

Thanks for correcting my post. I was fooled by the preview function which removed all line breaks and any markup.

Posted by: Wolfram Kroll [TypeKey Profile Page] on March 17, 2006 03:15 AM

hi..

I want to know about cruise control.what is that use?.please send me complete introduction about that.

Posted by: yugandhar on August 8, 2006 11:43 PM