28

Tried with the configure option, not able to find the tools configuration option and the git executable section. Seems like it occurs after a successful build only. Please help.

Here's the output I receive after building the project on the console output section:

  Building in workspace C:\Users\Anishas\.jenkins\workspace\Sample123
    Cloning the remote Git repository
    Cloning repository https://github.com/AnishaSalunkhe/HelloWorld.git
     > C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123 # timeout=10
    ERROR: Error cloning remote repo 'origin'
    hudson.plugins.git.GitException: Could not init C:\Users\Anishas\.jenkins\workspace\Sample123
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:656)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:463)
        at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1057)
        at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1097)
        at hudson.scm.SCM.checkout(SCM.java:485)
        at hudson.model.AbstractProject.checkout(AbstractProject.java:1269)
        at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:607)
        at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
        at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
        at hudson.model.Run.execute(Run.java:1738)
        at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
        at hudson.model.ResourceController.execute(ResourceController.java:98)
        at hudson.model.Executor.run(Executor.java:410)
    Caused by: hudson.plugins.git.GitException: Error performing command: C:\Users\Anishas\git init C:\Users\Anishas\.jenkins\workspace\Sample123
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1726)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1695)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1691)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommand(CliGitAPIImpl.java:1321)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$5.execute(CliGitAPIImpl.java:654)
        ... 12 more
    Caused by: java.io.IOException: Cannot run program "C:\Users\Anishas\git" (in directory "C:\Users\Anishas\.jenkins\workspace\Sample123"): CreateProcess error=5, Access is denied
        at java.lang.ProcessBuilder.start(Unknown Source)
        at hudson.Proc$LocalProc.<init>(Proc.java:240)
        at hudson.Proc$LocalProc.<init>(Proc.java:212)
        at hudson.Launcher$LocalLauncher.launch(Launcher.java:815)
        at hudson.Launcher$ProcStarter.start(Launcher.java:381)
        at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1715)
        ... 16 more
    Caused by: java.io.IOException: CreateProcess error=5, Access is denied
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 22 more
    ERROR: null
    Finished: FAILURE
StephenKing
  • 36,187
  • 11
  • 83
  • 112
Learner
  • 512
  • 2
  • 7
  • 23

16 Answers16

55

This wasted so much time on my Jenkins Windows slave.

I knew git was in the path because I executed "where git" in the build job's batch command.

where git
C:\Program Files (x86)\Git\cmd\git.exe

Apparently the Jenkins Git Plugin executes ** before ** the environment is inherited.

SET YOUR SLAVE's PATH to Git ( Just DO IT !! )

1) Go to your Windows slave configuration Manage Jenkins > Manage Nodes

2) Select your slave configuration

3) Check Tool Locations under Node Properties

4) Enter complete path to git executable including git.exe

[x] Tool Locations
   Name: (GIT) git
   Home: C:\Program Files (x86)\Git\cmd\git.exe

See screenshot:

enter image description here

Ed of the Mountain
  • 5,219
  • 4
  • 46
  • 54
17

Go to Manage Jenkins / Global Tool Configuration and set Path to Git executable:

enter image description here

Andre Hofmeister
  • 3,185
  • 11
  • 51
  • 74
Chandra Pal
  • 239
  • 2
  • 2
4

set the path to git.exe and not only to the directory of the git file in both the locations of tool configurations.

Learner
  • 512
  • 2
  • 7
  • 23
  • I wasted almost a day to reach this comment! Thanks. – Rvy Pandey May 13 '19 at 11:50
  • 1
    @RvyPandey How can you understand what he was saying? I read 5 times, still don't get it. – MiDaa May 22 '19 at 02:55
  • 2
    @MiDaa, I understand that if you directly read this answer, it is hard to comprehend. But if you read the whole thread (all the answers) you'll understand this too. He means that, in Jenkins > Global Tool Configuration > Git > Path to Git executable, set your tool path to C:\Program Files\Git\bin\git.exe, and not just C:\Program Files\Git\bin (or whatever path you have on your system). There are other answers that suggest this too, but this one was very straight forward for me. – Rvy Pandey May 22 '19 at 06:42
  • 1
    @RvyPandey Thanks, I solved it in another way by setting gittool in pipeline command. – MiDaa May 23 '19 at 07:02
4
  1. Check for below command in Jenkins Server in linux Env:
`whereis git`

you will get the path like /usr/bin/git

  1. Place it in Manage jenkin>Global Tool Configuration> under git path mention /usr/bin/git

  2. Rerun job again

3

Sometimes this error occurs when disk space is less. so do check the space of your machine where jenkins is hosted. :)

  • 1
    this can be added as a comment, instead of an answer, looks like OP has already got the problem resolved – nj2237 Apr 20 '18 at 12:19
2

If anyone is using Jenkins with freshly installed Xcode, you'll need to agree to the license using sudo xcodebuild -license or agree through UI.

Genki
  • 3,055
  • 2
  • 29
  • 42
2

There can be multiple reasons for that

  1. Check the Permission of the Folder or the Worker Node, In my case 3rd one was the issue because of not providing permissions to the users and groups. As a result you may need to do sudo chown -R user:group folderName
  2. Check you have configured the SSH Key, if you are using Private Repo from GitHub.
  3. Path Must be provided inside Jenkins Global Configuration of Default Git
Sergey Pleshakov
  • 7,964
  • 2
  • 17
  • 40
Mohit Sharma
  • 601
  • 6
  • 11
2

In my case,

  1. I have installed git on my slave server. Download-git
  2. Run cmd command

where git

and update your git path with exe file like below in Jenkins node configuration.

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

Go to your Windows slave configuration, Manage Jenkins > Manage Nodes > Select your slave > configure

Check "Tool Locations" under "Node Properties" and give the full path what you got from 'where git' command and save.

Aditya Y
  • 651
  • 6
  • 12
2

yes I have faced the same issue on the Linux ec2 instance but I fixed it through

  1. First of all on your server run the below command, and this command will return to you $ which git this command will return to you the actual path of the git, where your git is installed like that /usr/bin/git copy this path.
  2. open your Jenkins > go to manage Jenkins >Global tool configuration > paste the in this field "Path to Git executable you can see in the image
mudassar munir
  • 355
  • 1
  • 4
  • 18
1

Windows: 1. Install git in windows machine 2. The git.exe path is C:\Program Files\Git\cmd\git.exe (by default, unless you change during installation) 3.Now need to show the path of git.exe in Jenkins git plugin tool

a)manage Jenkins>Global Tool Configuration>Git

b)Add git : name: anything and Path:C:\Program Files\Git\cmd\git.exe 4. Then build for clone. Should be ok

Linux CentOS7: Same error message I got and after installation git in same machine were Jenkins installed, it is solved.

yum install git

shafi
  • 11
  • 2
1

Then you need to follow below steps. Hope so this may be useful for you to resolve your problem.

If your master is linux machine and slave is windows machine...

Pre-Requisites:

  • your slave machine should have same java version(jdk 1.8).
  • Git should be installed on your slave machine.

Steps to follow:

  1. Go to your Windows slave configuration Manage Jenkins > Manage Nodes

  2. Select your slave configuration

  3. Check Tool Locations under Node Properties

  4. Enter complete path to git executable including git.exe

Tool Locations
   Name: (GIT) git
   Home: C:\Program Files (x86)\Git\cmd\git.exe

See screenshot:

barbsan
  • 3,418
  • 11
  • 21
  • 28
Nikunj
  • 13
  • 3
1

1) Make sure the git.exe has executable permissions. 2) Make sure git is configured correctly to refer in Global Tool configurations and also on the Jenkins agent (windows in your case) where you running the job, environment variable for git.exe executable is set correctly

Azeem
  • 51
  • 5
1

have this problem after my company move to 2FA (2 factory authentication) at GitHub

in the Jenkins I get in credential this enter image description here

to fix it

  1. I create a personal access token in Github from here

2)after that i get to the same place in the jenkins when the errors ->Credential->add ->jenkins enter image description here

and get as you see in the picture down username= what you want name password = token that you get

enter image description here

Vladi
  • 1,662
  • 19
  • 30
1

Upgrading all plugins and Jenkins to 2.332.1 solved for me

ergunkocak
  • 3,334
  • 1
  • 32
  • 31
0

This answer may sound like a joke, but it resolved the exact error message we were getting for only 1 pipeline:

  • Check if the pipeline has a parameter with no name value.
NibblesMK
  • 21
  • 3
-1

Don't forget to Add your deploy key credentials (the deploy key attached to the github project) in jenkins (http://yourjenkinsurl:8080/credentials/)