Hudson CI testing for grails from git

Posted: 2009-04-18

After running continuous integration with continuum for a long while (which works great for maven projects) I decided to take a look at Hudson. It can also do maven - but seems to have a larger range of plugins available. Of interest to me was grails.

Installation

This was extremely simple - I just grabbed the hudson.war file from the hudson site and deployed it in a running glassfish.

LDAP configuration

This was a bit more complex. Under Manage Hudson > Configure System

Hudson LDAP config
Hudson LDAP config

Note the User/Group names - ROLEADMIN and ROLE_HUDSON. For this to work you need groupOfUniqueNames entries directly under the group search base (here ou=groups,dc=chrissearle,dc=net) with the names cn=admin and cn=hudson. Hudson will match this by removing ROLE and lowercasing the rolename. This was unclear in the hudson docs I was reading but google came to the rescue.

Plugins

To be able to test grails projects from git I installed the grails and git plugins (Manage Hudson > Manage Plugins > Available). Check them off (and any others you want) and then install them.

Each plugin will add a config section under Manage Hudson > Configure System.

For git:

Hudson - git
Hudson - git

Since git is in the path this is OK - otherwise set the full path.

For grails:

Hudson - grails
Hudson - grails

Here only grails 1.0.4 is configured - but you can add several different versions.

Project

Now lets add a grails project.

Choose New Job from the main menu.

Hudson - build
Hudson - build

Add a name and choose free-style.

To configure the project - choose git from the SCM configuration section - my projects have the ability to be cloned over http - so just add the clone URL as the git repository url. Set a branch if you're not testing master.

For build triggers - I chose to poll the SCM with the following schedule _/5 _ * * *

For build choose "Add build step" and choose Build with Grails. You'll need to pick which grails installation from the dropdown (these were configured above) and also target.

I normally add two grails build steps - one for target test, one for target war - so that if it fails then the notification tells me which step.

Finally set whichever notification options you want. Git specific is the ability to tag the original repository with the test.

Other plugins

For me the other plugins that are useful are JIRA (if the last commit message contains a JIRA tag then it will comment in the JIRA issue when the test passes), and email/jabber/irc/twitter notifications.