nologo
nologo

Reputation: 6288

teamcity - 'java' is not recognized as an internal or external command

i'm using teamcity 5.1.5.. trying to build an MSBuild project with an AfterDeploy target which calls a java function..

i get the following error: 'java' is not recognized as an internal or external command

I've tested the java command on the build server and the agent servers and they all run the command..but it seems it fails when running through teamcity.

any ideas?

i've checked the build agent env vars and they seem correctly setup:

Environment variables defined in the agent configuration file

JAVA_HOME C:\Program Files\Java\jdk1.6.0_21

JDK_16 C:\Program Files\Java\jdk1.6.0_21

TEAMCITY_JRE C:\TeamCity\jre

the only thing i notice is that the java.exe are actually in the bin folders here not the root folder.

Upvotes: 7

Views: 6610

Answers (3)

CrazyCoder
CrazyCoder

Reputation: 401975

Build Agent runs from the SYSTEM account by default. SYSTEM account environment variables differ from your normal account which you've used for testing. I suspect that java.exe is not in PATH for the SYSTEM account. Either adjust PATH by adding JDK_HOME\bin to it or configure the Agent service to run from a different account.

Remember you need to restart the build agent service before changes to PATH will take effect.

Upvotes: 5

ocroquette
ocroquette

Reputation: 3259

We run the agent under a normal user account. Java can be found in an interactive session, but not in the TeamCity builds. I had to add the java bin directory to the PATH variable of the user. After a log off/log in, the java command could then be found by the TeamCity builds.

Upvotes: 0

Sire
Sire

Reputation: 4348

You can also run your build agent service under a local administrator account (this might be preferred for several reasons), but there is a bug in TeamCity where only the USER environment variables (for example the PATH) are used by the agent, not SYSTEM+USER as normal in Windows.

So if you have a path defined for the user, the system paths are unknown by the agent!

The workaround right now (verified) is to add the user path to the system path and delete the user path (under System/Avanced System Settings/Environment Variables).

Bug here and a (not solved as of 2012-01-29): http://devnet.jetbrains.net/thread/276957

Upvotes: 1

Related Questions