Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm having a hard time configuring Jenkins, running as a Windows Service, to connect to a git server (gitosis) and clone a repository. Jenkins is set to use the standard Git plugin.

Everything is hosted by us: the Jenkins server is on win.foo.com and gitosis is running on a linux server (git.foo.com).

If I RDP into win.foo.com I can clone (git.exe clone --progress -o origin git@git.foo.com:myproject.git myproject) from the command line without issue.

Jenkins is running as a service and because it's not running under the same user account I've copied the .ssh folder to %SystemRoot%\System32\config\systemprofile (as defined in the %USERPROFILE% environment variable) and C:\Program Files (x86)\Git\, but neither of these seem to be picked up by Jenkins, even after a full restart.

I've tried using both git.exe and git.cmd; no joy in either case.

Jenkins is failing with the following error message:

ERROR: Error cloning remote repo 'origin' : Could not clone git@git.foo.com:myproject.git
ERROR: Cause: Error performing command: C:\Program Files (x86)\Git\cmd\git.cmd clone --progress -o origin git@git.foo.com:myproject.git C:\Program Files (x86)\Jenkins\jobs\myproject\workspace
Command "C:\Program Files (x86)\Git\cmd\git.cmd clone --progress -o origin git@git.foo.com:myproject.git C:\Program Files (x86)\Jenkins\jobs\myproject\workspace" returned status code 128: Cloning into C:\Program Files (x86)\Jenkins\jobs\myproject\workspace...
Access denied
fatal: The remote end hung up unexpectedly

I'm sure I've missed something, but I'm not sure what.

Advice?

share|improve this question

migrated from stackoverflow.com Aug 4 '11 at 9:42

This question came from our site for professional and enthusiast programmers.

    
@Mchl: quite true, actually... voted to close (migrate to SF) as well. –  VonC Aug 4 '11 at 8:36

2 Answers 2

I've been reading the following article, which is closely related: How do I tell Git for Windows where to find my private RSA key? and it gave a good hint: The HOME-Variable is crucial, but it didn't work out the way I thought.

After a lot of reasearch and trying I found this article: http://markashleybell.com/portable-git-windows-setting-home-environment-variable.html

In fact it is not enough to set the environment-variable in windows as usual, when running ssh from a service account, but change the configuration so the keys are actually found.

Short relevant outline:

Navigate to C:\Program Files\Git\etc\profile and add the following line

HOME="/c/Users/YourUserAccount"

before

# normalize HOME to unix path
HOME="$(cd "$HOME" ; pwd)"

This solved it for me, because now Git always uses your statically assigned path for home. Just make sure you don't get any security-issues with this approach with other users on this machine.

share|improve this answer

The only parameter you need to really check is the %HOME% environment variable value, when Jenkins tries to clone.
You need to display the 'set' (environments variable) of the Jenkins session and see if HOME has been defined, and if it has, to which path.

Reminder:

  • Windows, by default, doesn't define HOME
  • msysgit defaults HOME to %USERPROFILE%

To display the variables, use the Parametrized build feature:

Reference parameter by name in builder. I'm using the "env" command to show the variable, followed by an echo statement to demonstrate referencing the value:

command shell in parametrized Jenkins job

share|improve this answer
    
Any idea how I can view the %HOME% env variable through Jenkins? –  Phillip Oldham Aug 4 '11 at 8:15
    
@unpluggd: I have edited my answer to address your question. –  VonC Aug 4 '11 at 8:34
    
Thanks! Doesn't show that HOME is set though; as you said, HOME isn't set by default. Is it possible to set this? –  Phillip Oldham Aug 4 '11 at 9:02
    
@unpluggd: on Windows, HOME isn't set, that means you have to set it either on the User Environment Variable side, or on the System Environment variable side as in howtogeek.com/51807/… –  VonC Aug 4 '11 at 9:34
    
Still getting access denied! There's no HOME var even though Jenkins is now running as a new user. –  Phillip Oldham Aug 4 '11 at 11:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.