0

I have an application built on Grails 2.5.3 (https://github.com/ppazos/cabolabs-ehrserver).

I'm trying to integrate Travis-CI to run the tests of my app when I do a commit to GitHub. Here is my travis config file (the one I ended after a couple of hours of trial and error without luck): https://github.com/ppazos/cabolabs-ehrserver/blob/master/.travis.yml

language: groovy

sudo: false

jdk:
  - oraclejdk7

env:
  - GRAILS_VERSION=2.5.3

before_install:
  - rm -rf ~/.gvm
  - curl -s get.sdkman.io | bash
  - source "$HOME/.sdkman/bin/sdkman-init.sh"
  - echo sdkman_auto_answer=true > ~/.sdkman/etc/config
  - source "/home/travis/.sdkman/bin/sdkman-init.sh"
  # dev null is to avoid the need for user input https://github.com/sdkman/sdkman-cli/issues/101
  - sdk install grails $GRAILS_VERSION < /dev/null
  - sdk use grails $GRAILS_VERSION
  - grails -version
  - sdk current grails

branches:
  only:
    - master

script: sdk use grails $GRAILS_VERSION &&
        grails upgrade --non-interactive &&
        grails clean &&
        grails test-app -integration

The problem is that even sdkman reports that is using Grails 2.5.3 and grails version says the same, when the app is executed, I see this on Travis-CI UI:

|Loading Grails 2.4.4
|Configuring classpath
|Running pre-compiled script

It also tries to install old versions of plugins, not the version I have in my BuildConfig.

Here is the full output of the Travis-CI build: https://travis-ci.org/ppazos/cabolabs-ehrserver

I'm new to Travis-CI and I don't seem to find the problem, any help is very welcome!

Pablo Pazos
  • 3,080
  • 29
  • 42
  • Please tell me, if my updated `.travis.yml` from http://stackoverflow.com/a/34109788/2514164 solved this. If not, have you tried to set your `GRAILS_HOME` environment variable to `/home/travis/.sdkman/candidates/grails/2.5.3/` in the Travis-CI settings? – Peter Feb 23 '16 at 07:33

2 Answers2

0

I previously used SDKMAN (AKA GVM) to build my Grails projects on Travis, but using the Grails wrapper is a more reliable, simpler, and faster solution. Here's my Grails 2.5.1 project that I build with the Grails wrapper - notice that the Travis script is much simpler than yours, and because I don't need to install SDKMAN and Grails each time the build is run, it ought to be much faster.

All you need to do is commit the wrapper dir, and the scripts grailsw and grailsw.bat - don't copy them from my project, use those that are generated for a Grails 2.5.3 project (because they might have changed since Grails 2.5.1).

Dónal
  • 185,044
  • 174
  • 569
  • 824
  • After several tries I used the grails wrapper, just needed to add the database configuration and give execution permissions to grailsw. This is my final config: https://github.com/ppazos/cabolabs-ehrserver/blob/master/.travis.yml Now I have the travis status on my readme :D https://github.com/ppazos/cabolabs-ehrserver/blob/master/README.md – Pablo Pazos Feb 24 '16 at 02:01
0

The main problem was that I had an old pom.xml file in the project root and didn't knew that Travis-CI was using that to build the project. After I updated the pom (https://github.com/ppazos/cabolabs-ehrserver/commit/97d080bf9f7459732ca04faac10e6ae96d6ee3b3) it started to take the right version of Grails, v2.5.3, but another problem arose:

I have a JAR in my /lib folder that wasn't loaded by Maven, so the build failed because the missing classes. That is an internal lib developed my myself and it is only to be used by a couple of projects, so it is not published on any Maven repo.

Looking on the web, couldn't find any solution that works just to make Maven consider my JAR.

Pablo Pazos
  • 3,080
  • 29
  • 42
  • You could publish the JAR to bintray or GitHub, then add the location as a Maven repo – Dónal Feb 25 '16 at 14:14
  • @Dónal can you provide a link on how to add the location as a Maven repo? the jar is already on github. thanks! – Pablo Pazos Feb 25 '16 at 16:37
  • Here's an example https://github.com/domurtag/festivals/blob/master/grails-app/conf/BuildConfig.groovy#L61 – Dónal Feb 25 '16 at 18:29