git 设置 Github Jenkins 插件时出现“无法连接到存储库”错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12681308/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:42:39  来源:igfitidea点击:

"Failed to connect to repository" Error while setting up Github Jenkins Plugin

gitgithubjenkins

提问by micdoodle8

I am getting an error when inputting my repo location into the "Source Code Management > Git > Repository URL" section of a new Job. I have searched all around and tried many different URLs with no success.

将我的存储库位置输入到新作业的“源代码管理 > Git > 存储库 URL”部分时出现错误。我四处搜索并尝试了许多不同的 URL,但都没有成功。

Error:

错误:

Failed to connect to repository : Error performing command: git ls-remote -h https://github.com/micdoodle8/Crossbow_Mod_2.git HEAD

Any ideas? Thanks.

有任何想法吗?谢谢。

回答by ngm

You might need to set the path to your git executable in Manage Jenkins -> Configure System -> Git -> Git Installations -> Path to Git executable.

您可能需要在Manage Jenkins -> Configure System -> Git -> Git Installations -> Path to Git executable 中设置 git 可执行文件的路径

For example, I was getting the same error in Windows. I had installed git with chocolatey, and got the location via Powershell:

例如,我在 Windows 中遇到了同样的错误。我已经用巧克力安装了 git,并通过 Powershell 获取了位置:

Get-Command git.exe | Select Definition

In Unix, you should be able to do:

在 Unix 中,您应该能够执行以下操作:

which git

回答by cjs

on Jenkins ver. 2.7.4, the setting property of (Path to Git executable) is now in Manage Jenkins -> Global Tool Configuration -> Git -> Git Installations -> Path to Git executable.

在詹金斯版上。2.7.4,(Path to Git executable)的设置属性现在在Manage Jenkins -> Global Tool Configuration -> Git -> Git Installations -> Path to Git executable。

回答by Harshal Vaidya

I was getting the same thing while connection to git from jenkins. Here is few checklist you would like to watch on :-

从 jenkins 连接到 git 时,我得到了同样的东西。这里有一些你想看的清单:-

Jenkins Configuration :-
1) Check whether git executable is appropriately specified
2) Provide SSH repository link git@blahblah
3) Under credentials >> Select Username and Authentication key (go to your server, Generate SSH keys ssh-keygen... Copy keys to JENKINS_HOME/,ssh)
You should be able to connect to your GIT repository from Jenkins

Jenkins 配置:-
1)检查是否正确指定了 git 可执行文件
2)提供 SSH 存储库链接 git@blahblah
3)在凭据下>>选择用户名和身份验证密钥(转到您的服务器,生成 SSH 密钥 ssh-keygen...复制密钥到 JENKINS_HOME/,ssh)
您应该能够从 Jenkins 连接到您的 GIT 存储库

回答by Michael Kohler

You should install the Github Pluginfor Jenkins.

您应该为 Jenkins安装Github 插件

After installation, in "Configure" within the project, there should be an input field for "GitHub project". Input "https://github.com/micdoodle8/Crossbow_Mod_2" (without the quotes) there. Additionally you put the same in the input field which says "Repositories" (the one you mentioned in your question) beneath it.

安装后,在项目中的“配置”中,应该有一个“GitHub项目”的输入字段。在那里输入“https://github.com/micdoodle8/Crossbow_Mod_2”(不带引号)。此外,您将相同的内容放在输入字段中,该字段下方显示“存储库”(您在问题中提到的那个)。

回答by H.john

You might need to set the path to your git executable in Manage Jenkins -> global tool configuration -> Git -> Git Installations -> Path to Git executable.

您可能需要在 Manage Jenkins -> global tool configuration -> Git -> Git Installations -> Path to Git executable 中设置 git 可执行文件的路径。

回答by krishna

You have to set your pathto your Git executablewhich is in Global Tool Configurationof Manage Jenkins. We can find location of a path via window power-shell as: Get-Command git.exe | Select Definitionshown in pcture as: command for git executable path

您必须设置您的Git 可执行文件的路径,该文件位于Manage Jenkins 的全局工具配置中。我们可以通过window power-shell找到路径的位置: Get-Command git.exe | 选择pcture 中显示的定义为: git 可执行路径的命令

回答by Varun jain

The problem may occur when your system can not locate git installation. If you are using Jenkins on VM or local system, locate the git installation folder. For me (CentOS machine on AWS) it was in

当您的系统找不到git安装时可能会出现此问题。如果您在 VM 或本地系统上使用 Jenkins,请找到 git 安装文件夹。对我来说(AWS 上的 CentOS 机器)它在

/usr/bin/git

/usr/bin/git

Put this path in Jenkins in Manage Jenkins -> Configure System -> Git -> Git Installations -> Path to Git executable

把这条路径在Jenkins中 Manage Jenkins -> Configure System -> Git -> Git Installations -> Path to Git executable

https://i.stack.imgur.com/hSZ9N.png

https://i.stack.imgur.com/hSZ9N.png

回答by Nelson Dias

Hmmm....if you have jenkins running in a VM, make sure you install the package 'git-core' or 'git':

嗯....如果你有 jenkins 在 VM 中运行,请确保安装包“git-core”或“git”:

sudo yum install git

After all, we must have git installed in the machine where jenkins is running. Otherwise you won't be able to run git commands.

毕竟,我们必须在运行 jenkins 的机器上安装 git。否则你将无法运行 git 命令。