码迷,mamicode.com
首页 > 其他好文 > 详细

解决Jenkins上git出现的“ERROR: Error fetching remote repo 'origin'”问题

时间:2018-05-22 00:53:01      阅读:1444      评论:0      收藏:0      [点我收藏+]

标签:pre   efault   done   from   地址   exec   one   节点   nal   

这两天在搭建Jenkins环境,在构建新job时报ERROR: Error fetching remote repo ‘origin‘,具体错误如下:

Started by user wupan
Building in workspace /root/.jenkins/workspace/deploy
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url {url} # timeout=10
Fetching upstream changes from {url}
 > git --version # timeout=10
using GIT_ASKPASS to set credentials 
 > git fetch --tags --progress {url} +refs/heads/*:refs/remotes/origin/*
ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo ‘origin‘
hudson.plugins.git.GitException: Failed to fetch from {url}
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
	at hudson.scm.SCM.checkout(SCM.java:504)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
	at hudson.model.Run.execute(Run.java:1727)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress {url} +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: remote: Counting objects: 62, done.        
remote: Compressing objects:   4% (1/23)           
remote: Compressing objects:   8% (2/23)           
remote: Compressing objects:  13% (3/23)           
remote: Compressing objects:  17% (4/23)           
remote: Compressing objects:  21% (5/23)           
remote: Compressing objects:  26% (6/23)           
remote: Compressing objects:  30% (7/23)           
remote: Compressing objects:  34% (8/23)           
remote: Compressing objects:  39% (9/23)           
remote: Compressing objects:  43% (10/23)           
remote: Compressing objects:  47% (11/23)           
remote: Compressing objects:  52% (12/23)           
remote: Compressing objects:  56% (13/23)           
remote: Compressing objects:  60% (14/23)           
remote: Compressing objects:  65% (15/23)           
remote: Compressing objects:  69% (16/23)           
remote: Compressing objects:  73% (17/23)           
remote: Compressing objects:  78% (18/23)           
remote: Compressing objects:  82% (19/23)           
remote: Compressing objects:  86% (20/23)           
remote: Compressing objects:  91% (21/23)           
remote: Compressing objects:  95% (22/23)           
remote: Compressing objects: 100% (23/23)           
remote: Compressing objects: 100% (23/23), done.        
error: unpack-objects died of signal 15
fatal: unpack-objects failed

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2002)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1721)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:886)
	... 11 more
ERROR: Error fetching remote repo ‘origin‘
Finished: FAILURE

遇到问题后,开始了漫长的百度,有网友提供了下面几个解决的思路。

解决思路:

1、第一时间发现应该是权限问题,那么可以切换成git协议或者https的协议去获取。

2、如果不是协议的问题,看是不是git的路径错了导致的,再次配置节点的机器上的git路径。

3、如果是linux的机器,就要去确定是不是SSH的key导致的,而且用ssh去连接git,那么就要去配置ssh的key,这一点比较复杂也很重要。

 

解决方案:

一、权限问题导致

1、配置Jenkins的Git环境

Name:Git用户名,我配置的是GitHub的用户名,大家可以试试其他的

Path to Git executable:Git安装路径(Linux命令:which git、windows 命令: where git)

技术分享图片

2、把私钥拷贝到git配置中

在源码管理中,点击Add,添加秘钥

技术分享图片

Repository URL:git代码地址

Credentials:秘钥

技术分享图片

Kind:选择SSH Username with private key

Username:随便填写

Private Key:选择Enter directly

Key:系统生成的git id_rsa中的Key

2)输入完成后点击保存,源码管理中填写

Repository URL:git代码地址

Credentials:秘钥(选择刚才填写的UserName)

3)点击保存,重新构建Job,结果成功

 

二、将url改成http://用户名:密码@ip/的格式,git配置改成不使用密码(网友提供色解决方案未尝试,大家可以去试试)

 

如果有问题,可以在下面评论,谢谢

 

解决Jenkins上git出现的“ERROR: Error fetching remote repo 'origin'”问题

标签:pre   efault   done   from   地址   exec   one   节点   nal   

原文地址:https://www.cnblogs.com/feng0520/p/9070071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!