jenkins添加Git项目时报错Failed to connect to repository : Error performing git command: git ls-remote -h

原因分析:这是由于git客户端版本过低造成的!或者未安装git
Jenkins本机默认使用"yum install -y git" 安装的git版本比较低,应该自行安装更高版本的git。

查看GI版本

git --version

如果存在,卸载低版本

yum remove -y git

1、下载高版本

接着进行git版本升级操作:下载并安装高版本的git,下载地址:https://mirrors.edge.kernel.org/pub/software/scm/git/

[root@localhost ~]# yum -y install libcurl-devel expat-devel curl-devel  gettext-devel openssl-devel zlib-devel

[root@localhost ~]# yum -y install  gcc perl-ExtUtils-MakeMaker

[root@localhost ~]# cd /usr/local/src/

# 下面的地址就是通过之前的下载地址获取的
[root@localhost src]# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz

[root@localhost src]# tar -zvxf git-2.9.5.tar.gz

[root@localhost src]# cd git-2.9.5.tar

[root@localhost git-2.9.5]# make prefix=/usr/local/git all

[root@localhost git-2.9.5]# make prefix=/usr/local/git install

2、添加git到环境变量

[root@localhost git-2.9.5]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc

[root@localhost git-2.9.5]# source /etc/bashrc

3、查看更新后的git版本和所在路径

[root@localhost ~]# git --version

[root@localhost ~]# whereis git

4、进入jenkins设置

接着登录jenkins界面,依次打开"系统管理" -> "Global Tool Configuration" 全局工具配置-> "Git" -> "Path to Git executable",在此处填入"whereis git"查询出的地址 + "/bin/git" (如上面"whereis git"的地址为"/usr/local/git",则应该填入 "/usr/local/git/bin/git") 并保存。

最后再在Jenkins新建项目中源码管理Repository URL添加git地址,尝试多刷几次就可以了。

 

  • 8
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值