Building Grails Applications with Hudson

January 21st, 2008 by Mike Leave a reply »

I’m never surprised by the shear magnitude of stuff I don’t know about. Last week I stumbled upon Hudson as I was searching for help to configure Cruise Control to build and execute tests for my a Grails application. I found this post that introduced me to Hudson and got me started.

Let me first say that I was off to find a free solution. If I had the luxury of spending a little cash at this point I would have used Bamboo. I’m a big fan of Atlassian products and love what they are doing to integrate Jira, Fisheye, Bamboo, Crucible, Clover and Confluence. The traceability of code to issues to change sets to builds and tests is really cool. Anyway I digress.

So I found Hudson, and I was pleasantly surprised how easy it was to set up. I’m running on Windows with Tomcat 6 and JDK1.6. I simply deployed the Hudson WAR, and I was off to the races. Hudson’s configuration is all done via a web interface and the interface itself is very clean, especially compared to Cruise Control.

In Hudson I created a new job, selected SVN in the source code management section and entered the URL to my Grails app in the repository. Hudson also lets you configure a repository browser (ViewSVN, Fisheye, WebSVN or Sventon). Since I was already running Tomcat, I chose Sventon and quickly downloaded and deployed the WAR for Sventon. I set Hudson to poll SVN for changes every minute and for the build itself I told Hudson to use Ant (you need to set up ANT first in Hudsson) and pointed to the Grails build.xml.

I created two new targets in the build.xml: ‘all’ and ‘deploy’. The all target chains the depended targets together. I had originally had Hudson call test, war, deploy and doc separately but each invoked a compile separately.

<target name="all" depends="war, test, deploy, doc"
  description="build, test, deploy and build the javadoc"/>

I also created a deploy target that takes the war and deploys to Tomcat and property to specify the grails_env.

Under Post-build Actions I set the following properties:

  • Files to Archive = “**/*.war”
  • Javadoc Directory = “GRAILS-APP/docs/gapi”
  • Test Reports XMLs = “GRAILS-APP/test/reports/*.xml”

So in about an hour I had Hudson continually building, running my test cases, generating javadoc and deploying my WAR to Tomcat, and it was all relatively painless. Here’s what the job status screen looks like:
Hudson Screenshot

Going forward I’ll probably investigate using GANT instead of ANT, otherwise it’s serving the purpose.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

6 comments

  1. JS says:

    nice post. I tried the same … but I had a nasty exception: java.lang.ClassNotFoundException: org.apache.juli.ClassLoaderLogManager. did you?

  2. Mike says:

    No I didn’t see that exception.

    Here are some speciics on my environment:
    JVM: Java(TM) SE Runtime Environment 1.6.0_03-b05 Java HotSpot(TM) Server VM)
    OS: Windows XP (Service Pack 2) x86 5.1
    Container: Apache Tomcat/6.0.14

    I pulled down the latest stable build of Hudson at the time. Here’s what was in the pom.properties:
    #Generated by Maven
    #Thu Jan 10 02:20:38 GMT 2008
    version=1.167
    groupId=org.jvnet.hudson.main
    artifactId=hudson-war

    Here’s the link the the WAR I downloaded
    https://hudson.dev.java.net/files/documents/2402/81895/hudson.war

    Hopefully that might help narrow down what works and/or doesn’t

  3. Glad to hear that you liked it. I just wanted to point out that Hudson also has a JIRA integration so that you can go between builds and issues, and it can also go between builds and changesets, as you discovered.

    Regarding org.apache.juli.ClassLoaderLogManager class not found exception — JS, please file an issue to the Hudson issue tracker (http://hudson.dev.java.net/issues/) with the full stack trace if you can.

  4. JS, this is a know issue for the last (175) hudson build. Try with build 174 and see that everything will works fine.

    Mike, could you please tell what Hudson plugins are you using?

    Kind Regards

  5. Mike says:

    I’m actually not using any plugins. I’m trying out Redmine for issues management and there’s not a plugin available for that.

    I’m considering writing a grails plugin that will expose the information from grails stats, and provide a graph for that as well showing stuff like lines of code over time.

    What plugins are you using?

Leave a Reply

Powered by Web Design Company Plugins

Switch to our mobile site