49

I've installed Jenkins on my mac (osx lion). But I couldn't get it work. This is the stacktrace I've got:

Started by user anonymous

Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Using strategy: Default
Checkout:workspace / /Users/Shared/Jenkins/Home/jobs/test/workspace - hudson.remoting.LocalChannel@1c0a0847
Cloning the remote Git repository
Cloning repository origin
Error trying to determine the git version: Error performing command: /usr/local/git/ --version
Cannot run program "/usr/local/git/" (in directory "/Users/Shared/Jenkins/Home/jobs/test/workspace"): error=13, Permission denied
Assuming 1.6
ERROR: Error cloning remote repo 'origin' : Could not clone git@coding-squirrel.de:iRest.git
ERROR: Cause: Error performing command: /usr/local/git/ clone -o origin git@coding-squirrel.de:iRest.git /Users/Shared/Jenkins/Home/jobs/test/workspace
Cannot run program "/usr/local/git/": error=13, Permission denied
Trying next repository
ERROR: Could not clone repository
FATAL: Could not clone
hudson.plugins.git.GitException: Could not clone
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:1046)
    at hudson.plugins.git.GitSCM$2.invoke(GitSCM.java:972)
    at hudson.FilePath.act(FilePath.java:783)
    at hudson.FilePath.act(FilePath.java:765)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:972)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1195)
    at hudson.model.AbstractBuild$AbstractRunner.checkout(AbstractBuild.java:571)
    at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:460)
    at hudson.model.Run.run(Run.java:1404)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:238)
Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297

15 Answers15

94

The solution for me was to set the git path in the Manage Jenkins > Global Tool Configuration settings. In the Git section, I changed the Path to Git executable to /usr/local/bin/git.

Global Tool Configuration

Josh Brown
  • 52,385
  • 10
  • 54
  • 80
  • 16
    to get the actual path, you could type "which git" on command line to see the actual directory. This default might vary if you are in Mac mini, or mac mini os. – ssinganamalla Mar 13 '13 at 18:30
  • 4
    it works, for instance my path was like this C:\Program Files (x86)\Git\bin\git.exe – Mustafa Güven Jan 24 '14 at 11:36
  • 1
    This "Accepted Answer" should include the image from the answer below. The two answers combined were very very helpful to me! Thanks – Darksaint2014 Jul 01 '15 at 19:09
  • 11
    For Jenkins ver. 2.7.4, should be Manage Jenkins >Global Tool Configuration >Path to Git executable – Winbobob Sep 25 '16 at 20:03
34

Also you can set Git location in Jenkins server/node configuration:

goto Configure, under section Node Properties mark checkbox Tools Location and set yours path to Git.

enter image description here

AlekseiPetrovski
  • 1,016
  • 9
  • 17
24

It seems Jenkins has been changing a lot. I fixed this problem in March 2017 by doing this:

  1. Go to Manage Jenkins
  2. Go to Global Tool Configuration
  3. In Git / Path to Git executable enter C:\<whatever the path is>\git.exe.
  4. Click on Save.
Andrew
  • 7,602
  • 2
  • 34
  • 42
5

I had similar problem, the solution for Windows looks the same (my Jenkins is installed on a Windows machine):

Global settings:

Go to Manage jenkins -> Configure System -> Git installations add there the git exe path (for example: C:\Program Files\Git\bin\git.exe), or you can use environment variable.

For Jenkins version 2.121.3, Go to Manage jenkins -> Global tool configuration -> Git installations -> Path to Git executable: C:\Program Files\Git\bin\git.exe

Jenkins job side:

Go to Source code Management -> select git, add your repository, choose connection to repository (http/ssh) and add credentials and it should work.

schot
  • 10,958
  • 2
  • 46
  • 71
Amazia Gur
  • 1,692
  • 17
  • 16
5

Like Darksaint2014 said, you need to configure two parts if you installed Jenkins in Windows.

If you installed your Jenkins in windows, you need to install Git in both local and your linux server, then configure below in both locations:


Global tool configuration:

global tool configuration


For server side:

For server side


Michal
  • 2,078
  • 23
  • 36
Hailin Tan
  • 989
  • 9
  • 7
3

I had the correct path to git in Jenkins, but I had not yet accepted the Xcode build tools EULA on a fresh install of OS X Yosemite, so git looked like it was failing in Jenkins. After trying "git --version" on the git at /usr/bin/git in a terminal, I was given a command-line interface to accept the EULA, and then Jenkins could then access the git URL I had given the build project.

colbadhombre
  • 803
  • 8
  • 11
2

Another issue i faced with was, ssh.exe was not looking at the %userprofile%/.ssh folder for the key files. Instead it was looking to the folder C:\Program Files (x86)\Git\.ssh which was empty and which causes a hang due to ssh authentication prompt on the machine where git repo located.

We just copied the key files under %userprofile%/.ssh to C:\Program Files (x86)\Git\.ssh and the problem is resolved.

mehmet6parmak
  • 4,777
  • 16
  • 50
  • 71
1

I had a similar problem finding the git executable on OS X.

I had to change my Path to Git executable to : /usr/local/git/bin/git

Might give that a shot if you are still stuck.

mwopata
  • 36
  • 4
1

Please install git in your Jenkins server. For example, if you are using Red Hat Enterprise Linux where you are hosting Jenkins, then install git in that server using the following command: sudo yum install git This should solve the problem as git executable will be available in /usr/bin/git then and this will be recognized automatically by jenkins and this you can verify by navigating to Manage Jenkins --> Global Tool Configuration. Then under Git installations, there will not be any warning and now you should be able to clone your git project in jenkins. Hope this help the users.

1

Adding "/usr/bin/git" >> Path to Git executable, didn't work for me. Then I deleted the contents of $JENKINS_HOME/fingerprints and restarted Jenkins. The problem goes away.

1

I got a very similar error when my Jenkins agent was running Java 11 instead of Java 8. It had nothing to do with configuring my git path! Downgrading the agent to Java 8 was the only solution I found.

Max
  • 21,123
  • 5
  • 49
  • 71
0

If you do not copy and paste the full file path addess e.g. C:\Program Files\Git\bin\git.exe, in the 'path to executable' field when configuring Git, it can lead to errors. Windows 8 & 10 for instance have a 'copy path' functionality which really works and helps to get full path name. Mac should have something similar. Its always best to use that rather clicking in the path address address bar and copying. This does not usually give the full file path and may cause a lot of troubles if you forget to edit the path at its destination.

Path copycopy is also very good add-on for copying full path

enter image description here

0

In case the Jenkins is triggering a build by restricting it to run on a slave or any other server (you may find it in the below setting under 'configure')

enter image description here

then the Path to Git executable should be set as per the 'slave_server_hostname' or any other server where the git commands are executed.

Santosh Sindham
  • 879
  • 8
  • 18
0

For Jenkins 2.121.3 version, Go to Manage jenkins -> Global tool configuration -> Git installations -> Path to Git executable: C:\Program Files\Git\bin\git.exe It works!

In Jenkins, give the http URL. SSH URL shows similar error.

Sugandha Jain
  • 333
  • 2
  • 6
0

I had the same error, the problem was git not configured in jenkins, so the pipeline could not checkout the project.

To specify the Git path for Jenkins go to Dashboard > Manage Jenkins > Global Tool Configuration and set the path in the Path to Git executable field.

enter image description here

To verify if git is installed on you system run the command line

git --version

the result should look like

git version 2.34.1

if the result is command 'git' not found, can be install with.., then run the command like indicated:

apt install git

To know where Git is installed run the command line (for Linux users)

whereis git

another way is to install the git plugin in jenkins. You can check this link to know how: https://www.tutorialspoint.com/jenkins/jenkins_git_setup.htm

velocity
  • 1,630
  • 21
  • 24