Using Cloudbees BuildHive to test Grails Plugins

Cloudbees provides a simple Cloud-based continuous integration environment called BuildHive. Buildhive is like a simpler version of Jenkins where you can send all your public projects to be tested on someone else’s iron. It’s the perfect setup to ensure that all your grails plugins are ran correctly.

In this post, I will show you how to quickly set up and test a grails plugin to run on BuildHive.

I’m going to start with my grails-inflector plugin, which only has a few unit tests to ensure proper functionality. Let’s get started.

1. Upgrade to grails 2.1.

We will need to use the new grails wrapper functionality introduced in Grails 2.1 to build our application on BuildHive. For this, we need to download and install grails 2.1, and set our GRAILS_HOME environment variable to point to this correctly.

Once installed, I call ‘grails upgrade‘ to bring my application up to date with Grails 2.1.

2. Install grails wrapper

My application now runs on grails 2.1. All I need to do now is to generate the wrapper script to run my grails application on BuildHive.

I call ‘grails wrapper‘ to install the wrapper.

You should now see a few new files generated, wrapper, grailsw and grailsw.bat. Add them to git and commit your project back to github. You are done.

3. Add your project to BuildHive

Go to https://buildhive.cloudbees.com/ and sign in with your github account.

Click on ‘Add your Github Repository button’

Enable the project you want to build.

You should see a small green arrow to see the job that was created. Click on the link and then click ‘configure’.

In the shell script tab, type whatever grails commands you need to test your application.

Remember to use ./grailsw instead of the typical grails command.

In my case, this is ‘./grailsw test-app unit:

Save your changes and click on ‘Build now’

Click on the spinning bar, you should see the console output of your grails command. You should see that the wrapper is downloading your grails distribution and running your test.

The first time this is ran, it will take a long time as it sets up your environment. But any subsequent runs will be much faster.

Once the tests have finished running, you should see a blue success build light.

From now on, whenever you commit a new change into your application, BuildHive will run your tests and notify you of any results.

One thought on “Using Cloudbees BuildHive to test Grails Plugins

  1. Rob Fletcher

    This is really cool. The only problem I’ve found is executing command line tests (i.e. extending `AbstractCliTestCase`) as they are unable to run the Grails executable.

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s