Use sdkman inside teamcity?

Answered

Hi,

Running teamcity 8.1 to build grails apps.

I can't get sdkman to work inside the jobs. http://sdkman.io

Different branches of the app use different versions of grails, and I need to be able to choose the grails version based on what's checked out and building at the moment.

sdkman has 'sdk switch grails' command which does what I need, but it's not working inside of teamcity.

Thanks.

4 comments
Comment actions Permalink

Hi Ken,

Could you please try to run the same build via command line on TeamCity agent machine as noted in the guidelines? Do you get the expect result? 

0
Comment actions Permalink

I sort of got it working.

The problem is that the sdkman code depends on environment set up in .bashrc or .bash_profile. It messes with the path and environment variables.

I made a script that does this:

sdk switch grails

GRAILS=readlink -f $(/home/teamcity/.sdkman/grails/current)

$GRAILS test-app

...

0
Comment actions Permalink

The first part, sdk switch grails, reads the project's application.properties and chooses the correct grails version by setting a symbolic link, which is the 'current' part of the second line.

The second line reads the location of 'current' as an absolute path -- what current points to, rather than the path shown -- and puts that ultimate path into the GRAILS environment variable.

0
Comment actions Permalink

Hi Ken,

Glad that issue was resolved! Thank you for sharing your solution.

0

Please sign in to leave a comment.