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.