错误:
Failed to connect to repository : Command "/usr/bin/git ls-remote -h file:///home/myuser/path/to/project HEAD" returned status code 128: stdout: stderr: fatal: 'home/myuser/path/to/project' does not appear to be a git repository fatal: The remote end hung up unexpectedly
我尝试了以下方法:
chmod 777
chowned
jenkins:jenkins
当我运行上面的命令时:/usr/bin/git ls-remote -h file:///home/myuser/path/to/project HEAD在cmd上,我得到了分支。
/usr/bin/git ls-remote -h file:///home/myuser/path/to/project HEAD
我的问题是:
git ls-remote -h ...
git clone ...
我的环境:
RHEL 5.9
Jenkins 1.519作为服务安装(没有Web容器)
Git插件
Jenkins作为服务安装时,默认情况下,Jenkins不会像那样创建用户目录/home/jenkins。Jenkins的默认主目录设置为/var/lib/jenkins。如您所料,根据我的解决方法,jenkins无法从其他用户目录访问本地资源。
Jenkins
/home/jenkins
/var/lib/jenkins
jenkins
我将克隆的存储库移到了Jenkins的默认主目录下/var/lib/jenkins,即Repository URL在Jenkins Project的配置下,如下所示:file:///${JENKINS_HOME}/repo/<myprojectname>
Repository URL
file:///${JENKINS_HOME}/repo/<myprojectname>
更新: 以上工作正常…但是我从此博客中找到了一种更好的方法
步骤概述如下:
查找/etc/init.d/jenkins脚本。有一些$JENKINS定义的变量。这应该引导您前往sysconfig詹金斯,即/etc/sysconfig/jenkins。停止您的詹金斯实例:
/etc/init.d/jenkins
$JENKINS
sysconfig
/etc/sysconfig/jenkins
sudo /sbin/service jenkins stop
备份
cp /etc/sysconfig/jenkins /etc/sysconfig/jenkins.bak
在此文件中,更改以下属性:
$JENKINS_USER="<your desired user>"
更改所有相关Jenkins目录的所有权:
chown -R <your desired user>:<your user group> /var/lib/jenkins
chown -R <your desired user>:<your user group> /var/cache/jenkins
chown -R <your desired user>:<your user group> /var/log/jenkins
重新启动詹金斯,该错误应消失
sudo /sbin/service jenkins start
该错误现在应该消失了!