简体   繁体   中英

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

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.

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.

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

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

Get-Command git.exe | Select Definition

In Unix, you should be able to do:

which git

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.

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

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

You should install the Github Plugin for Jenkins.

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.

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

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

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

/usr/bin/git

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

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

First of all git should be properly installed in your system.

Check if after installing git, path is given in system environment variables. Add below paths in system variables "path" after installing git C:\\Apps\\Git\\bin C:\\Apps\\Git\\cmd

to test - run $ git -v in cmd prompt

Next, go to Manage Jenkins -> global tool configuration -> Git -> Git Installations -> Path to Git executable -> enter path like C:\\Apps\\Git\\bin\\git.exe (wherever your git is installed)

For detailed description on this issues and git setup in Jenkins, you can check this blog post - https://thewebspark.com/2020/07/24/git-and-github-setup-in-jenkins/

As described above by others, make sure that your Path to Git executable is right. Be careful though how you find it: git --exec-path might give you a wrong path, eg mine is C:/Program Files/Git/mingw64/libexec/git-core. Now, there IS a git.exe living there but this path in Path to Git executable seemed to be wrong. What you need is (sticking to my example above) C:\\Program Files\\Git\\bin\\git.exe

For Window it worked when I gave the complete path under the Global Tool Configuration:

C:\\Program Files\\Git\\bin\\git.exe

often times what happened to me was the directory was changed but the link for web hook still has the old directory. Maybe check that?

This error can be resolved, if we change the path of Git on Global Configuration Tools page.

Use Path- C:\Program Files\Git\bin\git.exe

For Detailed steps refer Click here

Hmmm....if you have jenkins running in a VM, make sure you install the package 'git-core' or '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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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