This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
6 Replies Last post: Dec 9, 2011 12:43 PM by Dmitry Neverov  
Johan Björk Newbie 41 posts since
May 3, 2011
Currently Being Moderated

Dec 1, 2011 10:19 PM

Usernames for git submodules

Hi,

 

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

[submodule "binaries"]

path = binaries

url = git@git.server.net: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.

 

Host git.server.net

User teamcity

 

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?

 

Thanks

/Johan

Dmitry Neverov JetBrains 313 posts since
Mar 29, 2010
Currently Being Moderated
Dec 2, 2011 1:43 PM in response to: Johan Björk
Re: Usernames for git submodules

Hi Johan,

 

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.

Dmitry Neverov JetBrains 313 posts since
Mar 29, 2010
Currently Being Moderated
Dec 8, 2011 1:29 PM in response to: Johan Björk
Re: Usernames for git submodules

Hi Johan,

 

we use System.getProperty("user.home") to get user home directory. I found following bugs

 

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4787931

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6519127

 

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.

Dmitry Neverov JetBrains 313 posts since
Mar 29, 2010
Currently Being Moderated
Dec 9, 2011 12:43 PM in response to: Johan Björk
Re: Usernames for git 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.

More Like This

  • Retrieving data ...