zoukankan      html  css  js  c++  java
  • Jenkins新建项目中源码管理Repository URL使用Git报错:Failed to connect to repository : Command "git ls-remote -h......

    之前部署了Gitlab+Gerrit+Jenkins持续集成环境,但在Jenkins中新建项目的源码管理"Repository URL"中添加git地址环节出现了问题,信息为"Failed to connect to repository : Error performing command: git ls-remote -h http://×××××××××.git HEAD",如下图:

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

    查看jenkins本机的git版本

    [root@jenkins ~]# git --version
    git version 1.7.1
    

    卸载本机低版本的git,自行安装更高版本的git

    [root@jenkins ~]# yum remove -y git            //或者使用"rpm -e --nodeps git"命令进行卸载
    [root@jenkins ~]# git --version    
    -bash: /usr/bin/git: No such file or directory
    

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

    [root@jenkins ~]# yum -y install libcurl-devel expat-devel curl-devel  gettext-devel openssl-devel zlib-devel
    [root@jenkins ~]# yum -y install  gcc perl-ExtUtils-MakeMaker
    [root@jenkins ~]# cd /usr/local/src/
    [root@jenkins src]# wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.1.1.tar.gz
    [root@jenkins src]# tar -zvxf git-2.1.1.tar.gz 
    [root@jenkins src]# cd git-2.1.1
    [root@jenkins git-2.1.1]# make prefix=/usr/local/git all
    [root@jenkins git-2.1.1]# make prefix=/usr/local/git install
    

    添加git到环境变量

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

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

    [root@jenkins ~]# git --version
    git version 2.1.1
    [root@jenkins ~]# whereis git
    git: /usr/local/git
    

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

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

  • 相关阅读:
    solr两种启动方式
    Centos7安装Solr
    关于netcore webservice 构建和参数大小控制问题
    百度开源ocr安装(飞浆)
    C# netcore 开发WebService(Soap)
    Aspose.CAD库简介 CAD转换PDF
    .net或JAVAK开发如何实现上传文件夹功能
    【转】TCP和SOCKET关系
    Asp.Net 绑定下拉框的值
    Windwos服务器远程桌面突然不能复制粘贴
  • 原文地址:https://www.cnblogs.com/kevingrace/p/5954042.html
Copyright © 2011-2022 走看看