Jenkins configuration of git plugin

若如初见. 提交于 2019-12-05 13:49:15

问题


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)


回答1:


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



来源:https://stackoverflow.com/questions/15257652/jenkins-configuration-of-git-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!