Jenkins Tomcat - 无法连接到存储库:无法初始化

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

问题:

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

我试过的:

过去两天我检查了大约 20 个 SO 问题和许多其他网站,并实施了其他人认为有用的解决方案,但无济于事。这是我尝试过的:

谁能告诉我是否遗漏了什么?在代理后面工作时我应该执行一些其他步骤吗?还是其他问题?

我遇到了这个问题,并使用 Process Monitor 调查了服务器上发生的情况。我发现了这个有助于查明问题的特定错误:

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

cmd window 中复制并粘贴命令会出现 C:\... is not recognized as an internal or external command... 错误。

Jenkins 试图在临时文件夹中执行 git init 命令。但是我注意到服务器上有问题的命令中 init 选项前面没有 git 可执行文件,这让我转向 Jenkins 配置中的 Path to Git executable 设置。我已经按照上面的样子配置它 (C:\...\cmd) 但将其视为一个简单的路径(即文件夹链)并且没有指定可执行文件。事实证明,Jenkins 只是获取该值并将其用作可执行文件的绝对路径。所以我通过向它附加 \git.exe 来解决这个问题,瞧!

tl;博士

确保 Jenkins 配置中的 Path to Git executable 是可执行文件的绝对路径,with 路径中存在的可执行文件:

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

此错误是由于 Git 在服务器上不可用。这可以通过在 Jenkins 服务器上安装 Git 来解决。

yum install -y git

有一个类似的问题,就像上面提到的@balan,它是 CI 服务器上的 git 不可用。为我工作

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

最初我在 Jenkins -> MyProjectName -> Configure -> Source Code Management =

解决办法=https://support.cloudbees.com/hc/en-us/articles/218156697-Git-Failed-to-connect-to-repository-Could-not-init-tmp