Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
805 views
in Technique[技术] by (71.8m points)

git plugin for Jenkins fails to clone a repo from local machine. Error code 128

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...