詹金斯间歇性git连接错误

Stu*_*art 6 git jenkins jenkins-plugins gitlab

我有一个 Jenkins 工作,在 99% 的时间里都没有问题,但偶尔我会在尝试获取时收到 Git 插件生成的错误。有问题的 Git 存储库托管在 GitLab 中。

此错误的来源可能是 Jenkins、网络连接或 GitLab。

我的问题是有没有人在 GitLab 或其他地方使用 Jenkins 和托管的 Git 看到过类似的问题?

堆栈跟踪(出于安全原因进行了编辑):

Building remotely on [MACHINE_NAME] (build) in workspace c:\workspace\location
 > C:\location\of\git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\location\of\git\bin\git.exe config remote.origin.url git@git.<gitlab-server>:My/project.git # timeout=10
Fetching upstream changes from git@git.<gitlab-server>:My/project.git
 > C:\location\of\git\bin\git.exe --version # timeout=10
using GIT_SSH to set credentials 
 > C:\location\of\git\bin\git.exe fetch --tags --progress git@git.<gitlab-server>:My/project.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@git.<gitlab-server>:My/project.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:797)
    ...
    at hudson.model.Executor.run(Executor.java:404)
Caused by: hudson.plugins.git.GitException: Command "C:\location\of\git\bin\git.exe fetch --tags --progress git@git.<gitlab-server>:My/project.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1752)
    ...
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:795)
    ... 11 more
ERROR: null
Warning: you have no plugins providing access control for builds, so falling back to legacy behavior of permitting any downstream builds to be triggered
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)

编辑(基于反对票)
迄今为止进行的研究(我正在定期运行 Jenkins 工作):

  1. 修改 Jenkins 以从 Jenkins 运行的机器上的特定文件中读取 ssh 私钥 - 间歇性观察到错误
  2. 将 ssh 私钥直接复制并粘贴到 Jenkins 中(以防文件访问权限问题 1。)- 间歇性观察到错误
  3. Git 命令在运行 Jenkins 的 Windows 机器上作为预定作业运行(尝试消除 Jenkins 作为问题的根源)- 等待结果...

如果第 3 点产生错误,那么我可以非常确定这是 GitLab 或网络连接问题。如果没有,那么我可以确定这是詹金斯的问题。如果有人在我之前注意到这个问题,我会很感激知道他们是如何解决它的。

更新(基于研究结果)

上面第 3 点中提到的作业在周末每小时运行一次。没有观察到错误。Jenkins 作业也在周末每小时运行一次,并观察到两个错误。 这支持了问题出在 Jenkins Git 插件上的理论。

Chr*_*aes 2

就我而言,问题是由于 sshd 中的“MaxStartups”指令造成的,该指令指定 SSH 守护程序的并发未经身份验证连接的最大数量(有关详细信息,请参阅 man sshd_config )。

当许多 Jenkins 作业同时运行时,这可能会导致与 SSH 守护进程的许多并发未经身份验证的连接,在这种情况下 sshd 将开始删除连接。您可以在 /etc/ssh/sshd_config 中设置“MaxStartups”指令,以增加 sshds 将开始删除连接的并发未经身份验证连接的数量(默认为 10)。

来自这个相关问题:https://serverfault.com/questions/924058/jenkins-occasionally-fails-to-clone-fetch