It'd like some clarification on how git submodules are checked out by teamcity.
Username in VCS-root is specified as 'teamcity'.
if a submodule is specified as follows
path = binaries
url = email@example.com:binaries.git
it always uses the "git" username, and not the one from the UI. Seems reasonable.
If we specify a ~/.ssh/config to override the user, it overrides the user on OSX and Linux, but not windows.
If we remove git from the path, it becomes a bit stranger.
On OSX/Linux, it seems to use the username from the user running the service, in our case 'teamcity'.
On Windows, I get submodule errors with authentication fail, so I'm guessing it uses the wrong username.
Is there any way to specify that all git repositories (including submodules) should use the username specified in the teamcity vcs-root UI?
If not, what actually determines the username for a checkout on Windows?
could you please explain what do you mean by 'remove git from the path'? As I understand the question is about server-side checkout, but on the server we don't use native git, so its presence in the $PATH should not matter.
Sorry, I meant from the 'path' in the .gitmodules file.
we use System.getProperty("user.home") to get user home directory. I found following bugs
they say that sometimes jvm returns incorrect user home dir. JVM takes value of parameter "Desktop" in the "HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders" entry in the registry, strip one dir from the end, and returns resulting value as a "user.home". Could you please do the same calculation, put .ssh/config in the resulting home directory and check if it makes TeamCity behaviour under windows the same as under other OSes.
Tried it, no luck. (It corresponded to the directory I used before, ie, the homedirectory of the user)
How does teamcity use the homedirectory? The agents use the native git.exe right?
Think I found it. ssh uses HOME environment variable, which in my case was set to something quite different.
How does teamcity make sure that the git-username configured serverside is used when checking out non-submodules?
Yes, agents use native git, but in order to use username configured on the server we use java ssh implementation on the agents. Before each fetch/clone on the agent TeamCity generates script in the agent temp directory which runs java ssh implementation and put path to this script into GIT_SSH environment variable, so when git is called it uses our script instead of real ssh. Also on the agents we first check if environment variable HOME is set and use it to find ~/.ssh/config, if it isn't set, then we use System.getProperty("user.home") as on the server.
You can make agent use native ssh (because java implementation is slower than native one, see http://youtrack.jetbrains.com/issue/TW-14598 for details). To do that set agent property
teamcity.git.use.native.ssh = false
But in this case you should configure user name in the ~/.ssh/config on the agent.