之前部署了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地址,尝试多刷几次就可以了。

Jenkins新建项目中源码管理Repository URL使用Git报错:Failed to connect to repository : Command "git ls-remote -h......的更多相关文章

  1. 【Devops】【docker】【CI/CD】Jenkins源代码管理 添加gitlab项目地址,报错Failed to connect to repository : Error performing command: ls-remote -h git@192.168.92.130:8090/root/swapping.git HEAD

    Jenkins源代码管理 添加gitlab项目地址 报错如下: Failed to connect to repository : Error performing command: ls-remot ...

  2. vue项目中一些标签直接放在<template>下会报错Failed to compile with 1 errors

    原因是a标签button以及element-ui的组件不能直接放在<template>下,需要先有一个div,其他标签要放在div下

  3. 【Devops】【docker】【CI/CD】jenkins源码管理,添加SSH地址后报错+Jenkins构建报错:Please make sure you have the correct access rights and the repository exists.

    jenkins源码管理,添加SSH地址后报错: Could not read from remote repository. Please make sure you have the correct ...

  4. 擦他丫的,今天在Django项目中引用静态文件jQuery.js 就是引入报错,终于找到原因了!

    擦 ,今天在Django项目中引用静态文件jQuery.js 就是引入报错,终于找到原因了! 问题在于我使用的谷歌浏览器,默认使用了缓存,导致每次访问同一个url时,都返回的是缓存里面的东西.通过谷歌 ...

  5. Win平台阅读Kafka源码时候使用bat脚本时候报错以及解决方案

    问题1: 使用bat脚本报错: 解决方案: 在配置好kafka的server.properties文件后,cmd进入命令窗口输入命令:.\bin\windows\kafka-server-start. ...

  6. 在angular项目中使用bootstrap的tooltip插件时,报错Property 'tooltip' does no t exist on type 'JQuery<HTMLElement>的解决方法和过程

    在angular4的项目中需要使用bootstrap的tooltip插件. 1. 使用命令安装jQuery和bootstrap npm install bootstrap jquery --save ...

  7. Jenkins连接git时出现“Failed to connect to repository : Command ... HEAD" returned status code 128:”的问题解决

    网上说的解决方法如下: 其实生成ssh时不应该使用当前用户去生成ssh,而是使用jenkins这个用户去生成ssh,然后再去git服务器上配置你生成key,最后再jenkins上配置返回给你的key. ...

  8. 项目中使用better-scroll实现移动端滚动,报错:Cannot read property 'children' of undefined better-scroll

    就是外面的盒子和要滚动的元素之间要有一层div, 插件挂载的元素是menuWrapper,可以滚动的元素是ul,在这两个元素之间加一个div元素即可解决问题.

  9. RHEL 7.2 源码安装Python 3.6.2报错

    报错代码:zipimport.ZipImportError: can't decompress data; zlib not available 一条命令解决:yum install zlib-dev ...

随机推荐

  1. Sql_server基本操作

    使用Sql_server创建表,视图,触发器,存储过程,函数等基本操作. create table test1( /* 创建一个表 */ num int ) alter table test1 /* ...

  2. EntityFramework Code-First 简易教程(十一)-------从已存在的数据库中映射出表

    怎样从一个已存在的数据库中映射表到 entity 实体? Entity Framework 提供了一个简便方法,可以为已存在的数据库里的所有表和视图创建实体类(entity class),并且可以用 ...

  3. 32_使用BeanUtils工具包操作JavaBean

      由于对属性设置值和得到值的需求很多,使用频率很高,所以有一些开源勇士 不满足于JavaBean API 中IntroSpector来操作bean, 写出来了通用的BeanUtils工具,来进一步简 ...

  4. 【PAT】B1079 延迟的回文数(20 分)

    用了柳婼大佬博客的思路,但实现有不同 没有用string所以要考虑字符串末尾的'\0' 用的stl中的reverse逆置字符串 #include<stdio.h> #include< ...

  5. Linux运维之如何查看目录被哪些进程所占用,lsof命令、fuser命令

    之前将一块硬盘挂载到某个目录下,但是现在我想卸载掉这块硬盘,无论如何都umount不了,有些同学可能说需要加上 -f 参数强制卸载,理论上是可以的,但是在我这里依然不起作用,比如: [root@:vg ...

  6. Linux 用户名、主机添加背景色

    文章参考:PS1应用之——修改linux终端命令行各字体颜色 Linux 用户名.主机添加背景色,用于生产环境,这样可以减少人为的误操作. [root@zhang ~]# tail /etc/bash ...

  7. switch语句(初学者)

    C语言提供了另一种用于多分支选择的switch语句(常用于开关),一般形式为: switch ( 常量表达式 ) { case 常量1 :语句; case 常量2 :语句; case 常量3 :语句; ...

  8. MySQL的并发控制与加锁分析

    本文主要是针对MySQL/InnoDB的并发控制和加锁技术做一个比较深入的剖析,并且对其中涉及到的重要的概念,如多版本并发控制(MVCC),脏读(dirty read),幻读(phantom read ...

  9. 点击事件click和onclick的区别

    一句话:$(selector).click()事件只能绑定静态元素.$(selector).on('click',function(){ })支持动态绑定元素. 如果是动态生成的元素,绑定事件只能用o ...

  10. mysql explain(转)

    explain显示了mysql如何使用索引来处理select和表连接 转自http://blog.csdn.net/zhuxineli/article/details/14455029 explain ...