简体   繁体   English

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

[英]git repository gives 403 error while connecting from jenkins in linux

Hi I just want to configure my project from github to jenkins to generate build. 嗨,我只想将我的项目从github配置为jenkins以生成构建。 I'm getting following error 我收到了以下错误

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

在此输入图像描述

I have added git path at Global Tool Configuration also. 我也在Global Tool Configuration中添加了git路径。 I've setup jenkins in linux centos server. 我在linux centos服务器上安装了jenkins。

I have found few similar questions in stackoverflow but that doesn't give a solution 我在stackoverflow中发现了几个类似的问题但是没有给出解决方案

Can anyone please tell me what may be wrong in that ? 谁能告诉我这可能有什么问题? Thanks in advance 提前致谢

A bit late, but this solutions works for me. 有点晚了,但这个解决方案适合我。 Just change the URL from 只需更改网址即可

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

to

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

Try creating an SSH Key. 尝试创建SSH密钥。 This will allow passwordless communication between your jenkins server and Github. 这将允许您的jenkins服务器和Github之间进行无密码通信。

Run the following commands from your jenkins server(as root): 从jenkins服务器(以root身份)运行以下命令:

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

Then, login to the github UI, go to SSH Keys, then paste the output of the last command into a new key. 然后,登录到github UI,转到SSH密钥,然后将最后一个命令的输出粘贴到新密钥中。

You should be good to go at this point. 你应该好好去这一点。

I also faced similar issue when configuring GIT in jenkins. 在jenkins中配置GIT时我也遇到了类似的问题。 After some investigation I found out that jenkins using default git installation which is 1.7.1 version. 经过一番调查后,我发现jenkins使用默认的git安装,即1.7.1版本。 Then I installed the latest version and configured jenkins to use the latest version. 然后我安装了最新版本并配置了jenkins以使用最新版本。 Click on Maange Jenkins -> Global Tool Configuration -> Git to find the configuration section. 单击Maange Jenkins - > 全局工具配置 - > Git以查找配置部分。

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM