Reputation: 430
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.
Upvotes: 38
Views: 113705
Reputation: 350
First- We need to install Git on our VM "sudo yum install git"
Second- Check is it install or not "git -v"
Third- Check the installed Path "which git"
Fourth- Add Path "Manage Jenkins -> global tool configuration -> Git -> Git Installations -> Path to Git executable."
Fifth- Save and restart http://xyz:8180/restart
Upvotes: 0
Reputation: 1
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
Upvotes: -1
Reputation: 11
For Window it worked when I gave the complete path under the Global Tool Configuration:
C:\Program Files\Git\bin\git.exe
Upvotes: 0
Reputation: 21
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
Upvotes: 2
Reputation: 1
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, e.g. 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
Upvotes: 0
Reputation: 1518
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/
Upvotes: 1
Reputation: 121
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.
Upvotes: 2
Reputation: 179
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
Upvotes: 3
Reputation: 21
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
Upvotes: 1
Reputation: 21
You might need to set the path to your git executable in Manage Jenkins -> global tool configuration -> Git -> Git Installations -> Path to Git executable.
Upvotes: 2
Reputation: 341
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.
Upvotes: 22
Reputation: 7487
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
Upvotes: 50
Reputation: 753
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.
Upvotes: 1