For quite a while I have been stuck using grails 2.2.0 on a Travis CI build server due to any later version not being added to the groovy ppa on ubuntu. This was done because of the move to the GVM tool. I was able to cobble together a travis script and GVM hack to get this working. This is great because now I can use Grails 2.2.1, 2.2.2, etc.
The Hack
When setting up the script I noticed that it was failing due to a return code of 1. I forked and inspected the GVM code and identified a fix. It needed to return a 0 after it does the install.
I have submitted a pull request to fix the return issue in the gvm-install.sh script, but in the meantime you will need to keep the bit in the before-install block where it grabs my file and replaces the current one as seen in the script below.
The Setup
Travis appears to come with a package called GVM already on the box for Go language management. We have to remove that first via rm -rf ~/.gvm
. We are then free to install GVM as it will not fail the check for the ~/.gvm directory.
Travis doesn’t like you to pipe commands back to bash as suggested in the GVM docs via curl -s get.gvmtool.net | bash
so we have to get the install script and stick it into local file to execute. We do this via this code block.
1 2 3 |
|
We then have to tell GVM to not prompt us defaults during install by appending to the config echo "gvm_auto_answer=true" > ~/.gvm/etc/config
.
Then we hack the install with my pull (which can hopefully be removed later) via curl -s https://raw.github.com/ctoestreich/gvm/master/src/main/bash/gvm-install.sh > ~/.gvm/src/gvm-install.sh
After that we are golden to set up the source and install any version of grails we need.
1 2 3 |
|
The rest of the build file is pretty vanilla.
The Script
Here is the .travis.yml script that you will need for your project and a link to a working example.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
|
Once the pull request is complete you will be able to remove the line:
1
|
|