Jenkins git fetch 间歇性失败

Tom*_*ley 5 git jenkins

似乎一些过夜的 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
Run Code Online (Sandbox Code Playgroud)

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

小智 5

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

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

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


小智 -1

出现此类问题有两种可能的原因。

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

  • 这是一个间歇性问题,因此详细信息必须正确。 (2认同)