gittomcatjenkinsbitbucket

Jenkins with Tomcat - Failed to connect to repository : Could not init


Issue:

Failed to connect to repository : Could not init D:\Work\apache-tomcat-7.0.59\temp\hudson4595160075978517187tmp

What I have tried:

I have checked ~20 SO questions and a lot of other websites in the last two days and implemented solutions others found helpful, but to no avail. Here's what I've tried:

Can anyone please tell me if I'm missing something here? Should I perform some other steps while working behind a proxy? Or is it some other issue?


Solution

  • I had this problem and investigated what's happening on the server using Process Monitor. I found this particular error which helped pinpoint the issue:

    java.exe  CreateFile  C:\Users\...\AppData\Local\GitHub\PortableGit_blabla\cmd init C:\Users\...\AppData\Local\Temp\hudsonblablatmp NAME INVALID
    

    Copying and pasting the command in a cmd window comes up with the C:\... is not recognized as an internal or external command... error.

    What happens is that Jenkins is trying to execute the git init command in a temporary folder. But I noticed that there is no git executable in front of the init option in the problematic command on the server, which turns me to the Path to Git executable setting in Jenkins' configuration. I had configured it as is looks above (C:\...\cmd) but treated it as a simple path (i.e. chain of folders) and not specified the executable. Turns out that Jenkins is just getting that value and uses it as an absolute path to an executable. So I fixed that by appending \git.exe to it and voilĂ !

    tl;dr

    Make sure that the Path to Git executable in Jenkins' configurations is the absolute path to the executable, with the executable present in the path:

    e.g. c:\Users\User\AppData\Local\GitHub\PortableGit_<guid>\cmd\git.exe