Jenkins git fetch intermittent failure



似乎一些通宵的 Jenkins 作业间歇性地失败,所以它们只是有时失败。控制台输出如下:

Started by timer
Checking out git ssh://git@gitlab.domain.com:2222/repo-here.git into /opt/jenkins/home/workspace/job_name@script to read Jenkinsfile
Wiping out workspace first.
Cloning the remote Git repository
Cloning repository ssh://git@gitlab.domain.com:2222/repo-here.git
> git init /opt/jenkins/home/workspace/job-name@script # timeout=10
Fetching upstream changes from ssh://git@gitlab.domain.com:2222/repo-here.git
> git --version # timeout=10
using GIT_SSH to set credentials GitLab SSH Key for  jenkins
> git fetch --tags --progress ssh://git@gitlab.domain.com:2222/repo-here.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress ssh://git@gitlab.domain.com:2222/repo-here.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:2002)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1721)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:72)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:405)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:614)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1146)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:113)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:144)
at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:67)
at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:298)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
ERROR: Error cloning remote repo 'origin'
ERROR: Maximum checkout retry attempts reached, aborting
Finished: FAILURE

詹金斯版本:詹金斯版本2.126 Git:3.9.0
Git 客户端插件:2.7.2 操作系统:中操作系统

我在另一个线程上找到了一个解决方案,为我解决了完全相同的问题: https://serverfault.com/questions/924058/jenkins-occasionally-fails-to-clone-fetch

如果你有几个 Jenkins 作业通过 ssh 同时获取 git 存储库,那么你应该在 git 服务器端增加/etc/ssh/sshd_config 中MaxStartups的值。

默认值为 10:30:100(这意味着当已经打开 30 个连接时,将丢弃 10% 的新连接(,我设置值 30:30:100,然后我就没有问题了。

有2 种可能的共振可以解决此类问题。

  1. 根据日志,我们得到的状态代码为 128。因此,交叉检查用户是否有权访问您正在克隆的存储库和分支。
  2. 请确保使用正确的存储库名称和分支名称。 其他明智的类似类型将会发生。

最新更新