13

I get this error when configuring git repo in a new jenkins project:

Failed to connect to repository : Error performing command:  ls-remote -h file:///c:\Dev\git\rx HEAD

I have a local git repo on my windows machine and cloning the same path from command prompt works on the same machine. I don't know what could be the problem (git.exe is on system path)

Gmt
  • 569
  • 1
  • 5
  • 19

1 Answers1

12

Windows installs Jenkins as a service. But it runs the Jenkins service under different user permissions that don't have access to GIT. You can follow this link to find the user that Jenkins runs under. http://antagonisticpleiotropy.blogspot.com/2012/08/running-jenkins-in-windows-with-regular.html

For example. My local user name on my windows is "nathandrewsire", exclude the quotes. Open windows services manager (either cmd and c:\services.msc, OR use windows key + R). Enable Log On > This account:. Then type in .\username (e.g. .\nathandrewsire). Then restart the service and you will have access to GIT from Jenkins builds.

I also found a snippet for windows shell command that will output the user to verify it. echo %PATH% echo %USERDOMAIN%\%USERNAME%

http://antagonisticpleiotropy.blogspot.com/2012/08/running-jenkins-in-windows-with-regular.html

Linux

If you're using Linux, this error can also be caused from not enabling share on your Git repo. Linux jenkins user won't be able to access Git report under another user unless.... git --bare init --shared=group Also, your jenkins user and Git repo user must belong to the same group for file permission access. There's other alternatives to that like messing with umasks and ACL's but setting up a linux group for your two users is the easiest way.

Make sure NOT TO OVERWRITE your Git repo with the bare init command. If you already have a Git repo, you'll need to setup/move to a new one with the shared option. I didn't see a way to convert existing repos to shared because I am guessing the files would all need to be updated?

NOTE*** I used VMWare Workstation shared folders to build on a windows guest. Jenkins needs the following format when entering the Git repo.

//vmware-host/Shared Folders/vm-share/ridcyDevelopment.git/

Unable to get Jenkins and Git to play nice

Community
  • 1
  • 1
  • 1
    for finding the username on Windows you can just run this: whoami – Steve Oct 25 '13 at 10:21
  • Finally an answer that helped run Jenkins on Windows Server 2008 box. Thank you! – Leniel Maccaferri Apr 14 '15 at 12:50
  • I'm on Windows, your tip didn't help, I get the same error :( – Maria Ines Parnisari Jan 05 '16 at 01:17
  • For Linux users: If you follow the instructions above (initializing the git repo with shared group as well as adding the `jenkins` user to the correct user group), you probably still need to restart Jenkins service with `sudo service jenkins restart` to make the changes take effect. – yaobin Aug 06 '18 at 18:01