【问题标题】:git repository gives 403 error while connecting from jenkins in linux从 linux 中的 jenkins 连接时,git 存储库出现 403 错误
【发布时间】:2017-08-17 12:49:39
【问题描述】:

您好,我只想将我的项目从 github 配置到 jenkins 以生成构建。 我收到以下错误

Failed to connect to repository : Command "/usr/bin/git ls-remote -h 
https://github.com/xxxxx/yyyyy.git HEAD" 
returned status code 128:
stdout: 
stderr: error: The requested URL returned error: 403 Forbidden while 
accessing https://github.com/xxxxx/yyyyy.git/info/refs

fatal: HTTP request failed

我还在全局工具配置中添加了 git 路径。我已经在 linux centos 服务器上设置了 jenkins。

我在 stackoverflow 中发现了一些类似的问题,但这并没有给出解决方案

谁能告诉我这可能有什么问题? 在此先感谢

【问题讨论】:

  • 我查看了上述问题的答案并尝试过,但无法解决这个问题。在这里我使用的是安装在 linux centos 中的 jenkins
  • 由于您使用的是 https URL,因此您的凭据是否与您的 GitHub 登录名/密码匹配(提示:您的 locgin 不是电子邮件地址)。您是否为您的 GitHub 帐户激活了 2FA(双因素身份验证)?
  • 是的凭据与 GitHub 帐户匹配,我没有激活 2FA。
  • 您能否在另一台机器(如 windows)中检查该进程,以确认您的确认是否与 URL 或 Linux 机器中为 git 访问和 jenkins 提供的权限有关。

标签: git github jenkins build centos


【解决方案1】:

尝试创建一个 SSH 密钥。这将允许您的 jenkins 服务器和 Github 之间进行无密码通信。

从您的 jenkins 服务器(以 root 身份)运行以下命令:

sudo su -s /bin/bash jenkins
cd ~
ssh-keygen -t rsa  (Hit enter for all prompts)
cat .ssh/id_rsa.pub

然后,登录 github UI,转到 SSH Keys,然后将最后一个命令的输出粘贴到新密钥中。

此时你应该很高兴。

【讨论】:

    【解决方案2】:

    在 jenkins 中配置 GIT 时,我也遇到了类似的问题。经过一番调查,我发现詹金斯使用默认的 git 安装,即 1.7.1 版本。然后我安装了最新版本并配置jenkins使用最新版本。点击 Maange Jenkins -> 全局工具配置 -> Git 找到配置部分。

    【讨论】:

      【解决方案3】:

      有点晚了,但这个解决方案对我有用。只需将网址更改为

       https://github.com/xxxxx/yyyyy.git
      

       https://youruser@github.com/xxxxx/yyyyy.git
      

      【讨论】:

      • @Sree --> 请将此标记为已接受的答案。经过几天努力解决这个问题后,这对我们来说非常有效。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 1970-01-01
      • 2020-07-03
      • 2014-05-14
      • 2013-11-13
      • 2019-05-12
      • 1970-01-01
      相关资源
      最近更新 更多