Travis CI is a cloud based continuous integration service. It’s a great way to automate test runs for projects hosted on GitHub. Since the Grails wrapper was added to Grails in version 2.1 you can use Travis to build Grails apps.
Travis is configured with a .travis.yml file in the root of your project. A simple configuration might look like this
language: groovy script: ./grailsw refresh-dependencies && ./grailsw test-app
refresh-dependencies command ensures that plugins and libraries are installed and available on the classpath when
test-app runs. Without this you may find that
test-app will fail if your app contains compile time references to plugins or libraries.
You can chain together as many commands as you like in the
script section. For example one of my Grails plugins has the following configuration:
language: groovy jdk: - oraclejdk7 branches: only: - master script: ./grailsw refresh-dependencies && ./grailsw "test-app unit:" && cd test/apps/gson-test && ./grailsw refresh-dependencies && ./grailsw "test-app functional:"
This runs the plugin’s unit tests then changes directory into a test application and runs (headless) functional tests.
Travis will email you when builds fail and by default runs against all branches. In the example above I’ve configured it to only run when changes are pushed to master so that I can push unfinished changes to other branches without affecting the project’s build status.