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

混江龙づ霸主 提交于 2019-12-05 16:13:54

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

balan

This error is due to the non availability of Git on the server. This can be fixed by installing Git on the Jenkins server.

yum install -y git

Had a similar problem, Like @balan mentioned above it was unavailability of git on CI server. worked for me

$sudo apt-get update
$sudo apt-get install git 

The original error I was getting in Jenkins -> MyProjectName -> Configure -> Source Code Management =

The solution= https://support.cloudbees.com/hc/en-us/articles/218156697-Git-Failed-to-connect-to-repository-Could-not-init-tmp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!