Jenkins could not run git
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 [email protected]:iRest.git
ERROR: Cause: Error performing command: /usr/local/git/ clone -o origin [email protected]: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)
Solution 1:
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
.
Solution 2:
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.
Solution 3:
It seems Jenkins has been changing a lot. I fixed this problem in March 2017 by doing this:
- Go to Manage Jenkins
- Go to Global Tool Configuration
- In
Git / Path to Git executable
enterC:\<whatever the path is>\git.exe
. - Click on Save.
Solution 4:
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:
For server side:
Solution 5:
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.