Wednesday, September 17, 2008

TeamCity and Subversion with NTLM authentication

One of the subversion repositories I work with was just migrated to a brand new server. The server uses NTLM authentication. Everything works like a charm, except for TeamCity builds. It keeps throwing errors like: Cannot request dated revision from svn: svn: Authentication required for https://....Googling for the solution, it turns out the problem is with SVNKit. Apparently the workaround is to add a setting: svnkit.http.methods=Basic,Digest,NTLMGreat, so where do I put this setting? It needs to be set before the main JVM launches the server or agent. On the server that's simple enough. Adding the setting into the script that starts the TeamCity server process fixed that problem (hurray for unix scripts). On a Windows based build agent this is a lot less trivial, especially since the build agent runs as a service... I tried modifying all kinds of settings; build properties in TeamCity, agent properties, startup scrips (uhm, I mean batch files)... no dice. Some more digging leads to the wrapper that's used to launch the build agent service. Additional Java settings can be added to <BuildAgent Root>\launcher\conf\wrapper.conf : ... # Application parameters. Add parameters as needed starting from 1 wrapper.app.parameter.1=jetbrains.buildServer.agent.StandAloneLauncher wrapper.app.parameter.2=-ea wrapper.app.parameter.3=-Xmx384m wrapper.app.parameter.4=-Xrs wrapper.app.parameter.5=-Dlog4j.configuration=file:../conf/teamcity-agent-log4j.xml wrapper.app.parameter.6=-Dteamcity_logs=../logs/ wrapper.app.parameter.7=-Dsvnkit.http.methods=Basic,Digest,NTLM wrapper.app.parameter.8=jetbrains.buildServer.agent.AgentMain wrapper.app.parameter.9=-file wrapper.app.parameter.10=../conf/buildAgent.properties ...That works! Note that the extra svnkit setting needs to be inserted before the class name for this to work.

2 comments:

Torbjørn Marø said...

I realize it's a while since you did this configuration magic, but could you please provide a step-by-step of how you did this? Like..

1) Stop TeamCity windows services
2) Edit the conf file
3) Start the win services...

Please?!

Marnix said...

Hi Torbjørn Marø,

That's all there is to it; stop the service, edit the config file, start the service.

According to the TeamCity documentation, this fix is no longer needed as of version 4.0.2

If all this isn't working for you, please let me know what is going wrong. I may be able to help you figure this out.