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

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

问题描述

错误:

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 到repo文件夹(包含.git目录的文件夹)
  • chowned 到 repo 文件夹上的 jenkins:jenkins
  • 试图从这个本地 repo 文件夹克隆到另一个文件夹:这是有效的!
  • 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!

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

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.

我的问题是:

  1. 为什么 git ls-remote -h ... 命令应该在 git clone ... 时调用?
  2. 如何配置 jenkins git 插件以从本地仓库获取代码
  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

我的环境:

RHEL 5.9

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

Jenkins 1.519 installed as a service(no Web container)

Git 插件

推荐答案

当安装 Jenkins 作为服务时,默认情况下,Jenkins 不会像这样创建用户目录:/home/jenkins.Jenkins 默认主目录设置为 /var/lib/jenkins.正如您所料,根据我的解决方法,jenkins 无法从其他用户目录访问本地资源.

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.

我将克隆的存储库移动到 Jenkins 默认主目录下,即 /var/lib/jenkins 下,因此我在 Jenkins 项目配置中的 Repository URL 如下所示:file:///${JENKINS_HOME}/repo/

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

此处概述了步骤:

查找 /etc/init.d/jenkins 脚本.定义了几个 $JENKINS 变量.这应该会引导您进入 jenkins 的 sysconfig,即 /etc/sysconfig/jenkins.停止您的 jenkins 实例:

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

备份

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

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

In this file, change the following property:

$JENKINS_USER="<您想要的用户>"

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

Change ownership of all related Jenkins directories:

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

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

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

重新启动 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天全站免登陆