I have a Jenkins job that 99% of the time runs without issue but occasionally I am getting an error generated by the Git plugin when trying to fetch. The Git repo in question is hosted in GitLab.
The source of this error could be Jenkins, network connectivity or GitLab.
My question is has anyone seen a similar issue using Jenkins with Git hosted in GitLab or otherwise?
Stack Trace (redacted for security reasons):
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
Edit (based on down-vote)
Research carried out so far (I am running the Jenkins job on a regular schedule):
If point 3 produces the error then I can be quite sure it is a GitLab or Network Connectivity issue. If it does not, then I can be sure it's a Jenkins issue. If anyone has noticed this issue before I'd be grateful to know how they solved it.
Update (based on research results)
The job referred to in point 3 above was run hourly over the weekend. No errors were observed. The Jenkins job was also run hourly over the weekend and two errors were observed. This supports the theory that the issue is with the Jenkins Git plugin.
In my case the issue was due to the "MaxStartups" directive in sshd, which specifies the maximum number of concurrent unauthenticated connections to the SSH daemon (see man sshd_config for details).
When many Jenkins jobs are running concurrently, this may results in many concurrent unauthenticated connections to the SSH daemon, in which case sshd will start dropping connections. You can set the "MaxStartups" directive in /etc/ssh/sshd_config to increase number of concurrent unauthenticated connections at which sshds will start dropping connections (defaults to 10).
From this related question: https://serverfault.com/questions/924058/jenkins-occasionally-fails-to-clone-fetch
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With