Testing Grails With a Travis Build Matrix

An example Grails build configuration for creating a Travis build matrix.

Brandon Fish

Continuous integration testing can be configured to create a build matrix to test multiple configurations of a project using a single build configuration.  This can be useful if you want to test a Grails application with multiple Grails versions, to test plugins with multiple Grails versions, or to test using varying configuration values.

The Travis CI build tool has a build matrix feature which allows you to specify multiple configuration parameters in the .travis.yml configuration file and runs the build against all possible combinations of these parameters. In the following example, I use the Groovy enVironment Manager (GVM) to change Grails versions between tests. I found this blog post which details how to set up GVM for Travis and updated this approach to force the GVM install command to return success instead of the workaround given there. The env block in the .travis.yml specifies the different environment parameters which will be passed to each test run to create the build matrix:

language: groovy

jdk:
- oraclejdk6

env:
  - GRAILS_VERSION=2.2.4
  - GRAILS_VERSION=2.2.3
  - GRAILS_VERSION=2.2.2
  - GRAILS_VERSION=2.2.1
  - GRAILS_VERSION=2.2.0

before_install:
- rm -rf ~/.gvm
- curl -s get.gvmtool.net > ~/install_gvm.sh
- chmod 775 ~/install_gvm.sh
- ~/install_gvm.sh
- echo "gvm_auto_answer=true" > ~/.gvm/etc/config
- source ~/.gvm/bin/gvm-init.sh
- gvm install grails $GRAILS_VERSION || true

branches:
  only:
    - master

script: grails clean && grails upgrade --non-interactive && grails test-app --non-interactive --stacktrace

The example build result below shows the different Grails version on the right used for each build. The source code for this example project can be found on Github.

Example Travis build matrix output of a Grails project build using GVM

More information about configuring a build matrix for Travis can be found in the Travis CI documentation.

Share this Post

Related Blog Posts

JVM

A Standalone Service Tier with Spring

October 24th, 2013

Building a Standalone Service Tier with Spring Integration and RabbitMQ

Object Partners
JVM

Using the Groovy Console as a Java Production Support Tool

October 22nd, 2013

As an advanced debugging technique, the Groovy Console is a great tool for interactively working with Java or Groovy objects serialized from running code.

Object Partners
JVM

What I wish I knew about Grails before my first Grails Project

October 15th, 2013

Some thoughts and ideas on how I would go about my first Grails project, if I had the chance to start it over.

Neil Buesing

About the author

Brandon Fish

Sr. Consultant

Brandon has over 6 years of software development experience with Spring and related JEE technologies including the last year plus working on a large scale enterprise Grails application. He has successfully delivered client projects using a variety of technologies and filling many project roles including lead software developer, requirements gatherer, domain expert, systems administrator, offshore team manager, and Scrum master. He is passionate and up to date with best software development practices in order to deliver projects efficiently, meeting client expectations and with a high quality.