jenkins使用git的报错的解决方案

在使用Jenkins 构建时,输入git地址有两种,一种是通过ssh, 另一种是通过http,在输入后一般都会报错,因为无论哪一种方式,都需要通过验证。
添加认证
  • ssh方式: 输入git地址后,点击add添加认证用户(点击Jenkins),
  • kind 选项 选择SSH Username with private key
  • Scope 选项 选择全局…(Globle (jenkins,nodes,items )…)
  • username 输入root(我的Jenkins是以root身份运行的,所以也一定程度上避免了一些权限问题)
  • Private key 把你的私钥粘贴进去 (在本机生成公私钥后,把公钥放到git上,具体步骤不再详述,)
  • 下面三个选项不用填写,会自动生成
    点击add 添加
    在Credentials项,选择你添加的用户(root)
错误处理
  • stderr: GitLab: The project you were looking for could not be found.
    fatal: Could not read from remote repository.
    检查git地址是否输入正确
  • stderr: fatal: Authentication failed
    密钥输入错误,检查密钥,或者是权限(不是root用户)
  • ssh_exchange_identification: read: Connection reset by peer
    被远程服务器拒绝连接,查看远程git服务器是否允许你连接。具体解决点击此处
http方式

输入git地址后,添加认证,

  • kind 选项 选择 username with passwd

  • Scope 选项 选择全局…(Globle (jenkins,nodes,items )…)

  • username 输入登陆 git 时的用户名

  • password 输入登陆 git 时的密码

  • 下面三个选项不用填写,会自动生成

  • 点击 add 添加

在Credentials项,选择你添加的用户

错误处理
  • stderr: GitLab: The project you were looking for could not be found.
    fatal: Could not read from remote repository.
    检查git地址是否输入正确
  • stderr: fatal: Authentication failed for XXXX
    检查用户名或密码是否输入有误,或者是权限(不是root用户)
  • ssh_exchange_identification: read: Connection reset by peer
    被远程服务器拒绝连接,查看远程git服务器是否允许你连接,或者不允许本机连接git仓库
  • 6
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值