Jenkins can not clone Git repository over Git/SSH on Windows Jenkins can not clone Git repository over Git/SSH on Windows git git

Jenkins can not clone Git repository over Git/SSH on Windows


I've gone through these pains recently. Especially frustrating is the lack of error logs in this scenario: probably because MSysgit prompts user on the console when trying to recover - which doesn't get through Jenkins console.

Based on my experience here are a few key elements to watch for:

  1. a mix of both Msysgit and Cygwin installed: MSysgit worked better for me- but I assume you're using that too
  2. some people have more luck with <MSYSGIT_ROOT>\cmd\git.cmd than <MSYSGIT_ROOT>\bin\git.exe
  3. making sure your slave runs as the same user (which is not the default upon service-based installs).. - oh I see you got that too
  4. setting HOME variable for windows slaves explicity
  5. basically make sure the same .ssh keys are reached when under Jenkins.
  6. for debugging, I found it useful to create a test job with no SCM, but run git clone in an "Execute shell/batch" build step. That should reveal a bit more info. BTW, you can do an env in the same step and maybe ls %HOME%/.ssh

I think the above is what gave me a working a Windows 7 64bit Jenkins slave with git support - although I thought this had more to do with some other fine config detail than with 64 vs 32 bits. Good luck anyhow!


In the latest version of git, had to use %GIT_HOME%/cmd/git.exe, rather than %GIT_HOME%/bin/git.exe and figuring out the home directory of the user running the jenkins service.


Another issue i faced with was, ssh.exe was not looking at the %userprofile%/.ssh folder for the key files. Instead it was looking to the folder C:\Program Files (x86)\Git\.ssh which was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.

We just copied the key files under %userprofile%/.ssh to C:\Program Files (x86)\Git\.ssh and the problem is resolved.