Jenkins的git插件无法从本地机器克隆回购。错误代码128 [英] git plugin for Jenkins fails to clone a repo from local machine. Error code 128

查看:1808
本文介绍了Jenkins的git插件无法从本地机器克隆回购。错误代码128的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:

 无法连接到存储库:命令/ usr / bin / git ls-remote -h file: // home / myuser / path / to / project HEAD返回状态码128:
stdout:
stderr:fatal:'home / myuser / path / to / project'似乎不是git仓库
致命:远程终端意外挂起

我尝试了以下操作:




  • chmod 777 到repo文件夹(包含.git目录的文件夹)

  • chowned jenkins:jenkins 在repo文件夹中

  • 试图从本地repo文件夹克隆到另一个文件夹中:这可以工作!



当我运行上述命令时: / usr / bin / git ls-remote -h file:/// home / myuser / path / to / project HEAD 在cmd上我得到了分支。



我的问题是:


  1. 为什么 git ls-remote -h ... 命令,当它应该是 git clone ...

  2. 如何配置jenkins git插件从本地回购库获取代码

我的环境:

RHEL 5.9


$ b Jenkins 1.519作为服务安装(无Web容器)



Git插件

解决方案

安装不会创建用户目录,如 / home / jenkins 。 Jenkins的默认主目录设置为 / var / lib / jenkins 。从我的工作中,正如您所期望的那样, jenkins 无法从其他用户目录访问本地资源。



在Jenkins的默认主目录下,例如在 / var / lib / jenkins 下移动了我的克隆回购,因此我的 Repository URL 项目配置如下所示: file:/// $ {JENKINS_HOME} / repo /< myprojectname>



更新:
上述工作正常......但我发现了一个更好的方法来从这个博客



这里概述了步骤:

查找 /etc/init.d/jenkins 脚本。有几个 $ JENKINS 变量定义了
。这应该引导你到jenkins的 sysconfig ,即 / etc / sysconfig / jenkins
停止你的jenkins实例:
$ b $ p $ sudo / sbin / service jenkins stop



进行备份

cp / etc / sysconfig / jenkins /etc/sysconfig/jenkins.bak



在此文件中,更改以下属性:

$ JENKINS_USER =<您想要的用户>



更改所有相关Jenkins目录的所有权:

chown -R<您想要的用户>:<您的用户组> / var / lib / jenkins



chown -R<您想要的用户>:<您的用户组> / var / cache / jenkins



chown -R<您想要的用户>:<您的用户组> / var / log / jenkins



重新启动jenkins,该错误应该消失

sudo / sbin / service jenkins start



这个错误现在应该消失!

Error:

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

I have tried the following:

  • chmod 777 to the repo folder(folder containing .git directory)
  • chowned to jenkins:jenkins on the repo folder
  • tried to clone into another folder from this local repo folder: this works!

When I run the above command: /usr/bin/git ls-remote -h file:///home/myuser/path/to/project HEAD on cmd I get the branches.

My questions are:

  1. why is git ls-remote -h ... command called when it should be git clone ...?
  2. How to configure jenkins git plugin to fetch code from local repo

My environment:

RHEL 5.9

Jenkins 1.519 installed as a service(no Web container)

Git plugin

解决方案

When installing Jenkins as a service, by default, Jenkins does not create a user directory as in: /home/jenkins. Jenkins default home directory is set to /var/lib/jenkins. From my work-around, as you would expect, jenkins has trouble accessing local resources from other users directory.

I moved my cloned repo under Jenkins default home directory i.e. under /var/lib/jenkins so my Repository URLin Jenkins Project configuration looks like: file:///${JENKINS_HOME}/repo/<myprojectname>

UPDATE: The above works fine ...but I found a better way to do it from this blog

The steps are outlined here:

look up /etc/init.d/jenkins script. There are a few $JENKINS variables defined . This should lead you to the sysconfig for jenkins i.e. /etc/sysconfig/jenkins. Stop your jenkins instance:

sudo /sbin/service jenkins stop

Take a backup

cp /etc/sysconfig/jenkins /etc/sysconfig/jenkins.bak

In this file, change the following property:

$JENKINS_USER="<your desired user>"

Change ownership of all related Jenkins directories:

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

Restart jenkins and that error should disappear

sudo /sbin/service jenkins start

This error should go away now!

这篇关于Jenkins的git插件无法从本地机器克隆回购。错误代码128的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆