从linux中的jenkins连接时,git repository出现403错误

时间:2017-03-24 14:20:59

标签: git github jenkins build centos

您好我只想将我的项目从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

enter image description here

我还在Global Tool Configuration中添加了git路径。我在linux centos服务器中设置了jenkins。

我在stackoverflow中发现了几个类似的问题,但是没有提供解决方案

有人可以告诉我这可能有什么问题吗? 提前致谢

3 个答案:

答案 0 :(得分:2)

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

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

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

答案 1 :(得分: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密钥,然后将最后一个命令的输出粘贴到新密钥中。

此时你应该很高兴。

答案 2 :(得分:1)

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

enter image description here

相关问题