Problem scripting install of Windows TeamCity agent

I am scripting installation of the TeamCity agent. Here are the steps my script goes through:

  1. Downloads the from our TeamCity server and unzips it to C:\BuildAgent
  2. Sets up the file (attached)
  3. Unzips a Java 1.6 JRE to C:\BuildAgent\jre
  4. Edits C:\BuildAgent\launcher\conf\wrapper.conf so that equals "../jre/bin/java"
  5. Installs the service, using bin/service.install.bat
  6. Grants the LocalSystem user PTO rights for that service (Pause, Start, Stop)
  7. Opens port 9090 for incoming TCP traffic in firewall
  8. Starts the service, using bin/service.start.bat

The start service batch file outputs to stdout:
wrapper  | Starting the TeamCity Build Agent service...
wrapper  | Waiting to start...
wrapper  | TeamCity Build Agent started.

However, the service ends after a few seconds and the wrapper.log file (Full file attached) reads:

INFO   | jvm 1    | 2013/05/09 14:21:04 | Current Java runtime version is 1.6
INFO   | jvm 1    | 2013/05/09 14:21:04 | Launching agent with command:  [Too long, Elided]
INFO   | jvm 1    | 2013/05/09 14:21:04 | Could not create the Java virtual machine.
INFO   | jvm 1    | 2013/05/09 14:21:04 | Unrecognized option: -XX\:+HeapDumpOnOutOfMemoryError
INFO   | jvm 1    | 2013/05/09 14:21:04 | Agent process finished
INFO   | jvm 1    | 2013/05/09 14:21:04 | Agent has exited with code: 1
INFO   | jvm 1    | 2013/05/09 14:21:04 | Too short run time, most likely there is some installation problem: 0.047 sec.
INFO   | jvm 1    | 2013/05/09 14:21:04 | Launcher is exiting

If someone could inform me what my installation problem is, that would be much appreciated.

Comment actions Permalink

It seems JVM argument is incorrect, should be -XX:+HeapDumpOnOutOfMemoryError instead of -XX\:+HeapDumpOnOutOfMemoryError (there must not be \ char).

Comment actions Permalink

Thanks for pointing out the obvious! I had thought that couldn't be the problem, because I hadn't touched any of the TeamCity batch files, etc. But it turns out it's getting that argument from the wrapper.conf file, which has been slightly messed up by the java properties writer my script is using.

Thank you.

These java properties files are confusing - in some cases it seems like you need to escape colons in the values, but not in all cases? I had different errors when I had my server url as http://teamcity - I had to change it to http\://teamcity. Whereas here it seems that escaping the -XX:+HeapDumpOnOutOfMemoryError in wrapper.conf leads to problems.

Comment actions Permalink

I agree, it's a common gotcha. Hope eventually we'll get rid of wrapper.conf file on the agent.


Please sign in to leave a comment.