TeamCity Build Agent Getting Wrong JAVA_HOME

Wow, what a nightmare.

From the log:

[2014-02-12 12:03:20,016] out - ----------------------------------------- [ dminder Android::main #11 (buildId = 21) ] -----------------------------------------

[2014-02-12 12:03:20,030] out - Starting: bash /usr/local/gradle/bin/gradle --init-script /usr/local/teamcity/buildAgent/plugins/gradle-runner/scripts/init.gradle clean compile

[2014-02-12 12:03:20,030] out - in directory: /usr/local/teamcity/buildAgent/work/924e5c8735207a0d

[2014-02-12 12:03:20,056] err - bash /usr/local/gradle/bin/gradle --init-script /usr/local/teamcity/buildAgent/plugins/gradle-runner/scripts/init.gradle clean compile

[2014-02-12 12:03:20,066] out -

[2014-02-12 12:03:20,067] out - ERROR: JAVA_HOME is set to an invalid directory: /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java

[2014-02-12 12:03:20,068] out -

[2014-02-12 12:03:20,069] out - Please set the JAVA_HOME variable in your environment to match the

[2014-02-12 12:03:20,069] out - location of your Java installation.

[2014-02-12 12:03:20,070] out -

[2014-02-12 12:03:20,072] out - Process exited with code 1


I have tried setting JAVA_HOME:


  1. in the .profile file for the user
  2. in the .bash_profile file
  3. using launchctl setenv
  4. inside the launchctl plist file
  5. in the buildAgent/conf/buildAgent.properties file, with env.JAVA_HOME


None of that works. No idea where it's getting this ridiculous ancient path from, if I do set from the command line, JAVA_HOME does not appear.

Please sign in to leave a comment.