ERROR: Error cloning remote repo 'origin' timeout=10 错误

发布于 2023-01-20 15:55:51 字数 7152 浏览 166 评论 0

最近,我的 Jenkins 构建在执行时失败,git clone并显示以下错误消息:ERROR: Error cloning remote repo 'origin'。

  1. 首先我怀疑这是网络原因,可能是因为从 Bitbucket 克隆需要占用大量带宽git clone并导致这种断开连接。但是当我尝试在代理上进行 git clone 时,它​​运行良好。
  2. 然后我注意到timeout=10Jenkins 控制台日志里有,我突然想起前几天我从 git repo 中删除了一个非常大的文件夹,这可能会导致 repo 更大,所以可能需要更多时间来做一个完整的克隆和它超过了 Jenkins 默认的克隆超时10

谷歌搜索,最后我发现了这个问题 JENKINS-47660 这和我的问题是一样的。

解决方案

最后我在 Jenkins 的 Git clone 中找到了 Advanced clone behaviors 的属性,选中 Shallow clone 然后将 Shallow clone depth 设置为 1。(这个设置相当于 --depth 1),我将超时从 10 分钟更改为 15分钟。

完整日志如下

using credential d1cbab74-823d-41aa-abb7
 Wiping out workspace first.
 Cloning the remote Git repository
 Cloning with configured refspecs honoured and without tags
 Cloning repository https://git.company.com/scm/db/blog.git
  > C:\Program Files\Git\bin\git.exe init C:\agent\workspace\develop # timeout=10
 Fetching upstream changes from https://git.company.com/scm/db/blog.git
  > C:\Program Files\Git\bin\git.exe --version # timeout=10
 using GIT_ASKPASS to set credentials blwmv
  > C:\Program Files\Git\bin\git.exe fetch --no-tags --progress https://git.company.com/scm/db/blog.git +refs/heads/develop:refs/remotes/origin/develop
 ERROR: Error cloning remote repo 'origin'
 hudson.plugins.git.GitException: Command "C:\Program Files\Git\bin\git.exe fetch --no-tags --progress https://git.company.com/scm/db/blog.git +refs/heads/develop:refs/remotes/origin/develop" returned status code 130:
 stdout:
 stderr: remote: Counting objects: 1
remote: Counting objects: 242690, done.
 remote: Compressing objects:   0% (1/75028)
remote: Compressing objects:   1% (751/75028)
remote: Compressing objects:   2% (1501/75028)
remote: Compressing objects:   3% (2251/75028)
remote: Compressing objects:   4% (3002/75028)
remote: Compressing objects:   5% (3752/75028)
... ...
remote: Compressing objects: 100% (75028/75028), done.
 Receiving objects:   0% (1/242690)
Receiving objects:   1% (2427/242690)
Receiving objects:   1% (4762/242690), 972.00 KiB | 949.00 KiB/s
Receiving objects:   2% (4854/242690), 972.00 KiB | 949.00 KiB/s
Receiving objects:   3% (7281/242690), 1.38 MiB | 919.00 KiB/s
Receiving objects:   3% (8998/242690), 1.82 MiB | 645.00 KiB/s
Receiving objects:   4% (9708/242690), 1.82 MiB | 645.00 KiB/s
Receiving objects:   4% (9778/242690), 1.82 MiB | 645.00 KiB/s
Receiving objects:   5% (12135/242690), 1.82 MiB | 645.00 KiB/s
... ...
Receiving objects:  86% (209321/242690), 1.01 GiB | 2.08 MiB/s
     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2042)
     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1761)
     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$400(CliGitAPIImpl.java:72)
     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:442)
     at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:655)
     at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:153)
     at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler$1.call(RemoteGitImpl.java:146)
     at hudson.remoting.UserRequest.perform(UserRequest.java:212)
     at hudson.remoting.UserRequest.perform(UserRequest.java:54)
     at hudson.remoting.Request$2.run(Request.java:369)
     at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
     at java.util.concurrent.FutureTask.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)
     Suppressed: hudson.remoting.Channel$CallSiteStackTrace: Remote call to dendevu2uvbw01
         at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1743)
         at hudson.remoting.UserRequest$ExceptionResponse.retrieve(UserRequest.java:357)
         at hudson.remoting.Channel.call(Channel.java:957)
         at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
         at sun.reflect.GeneratedMethodAccessor1074.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:498)
         at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
         at com.sun.proxy.$Proxy124.execute(Unknown Source)
         at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152)
         at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
         at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124)
         at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93)
         at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80)
         at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
         at java.lang.Thread.run(Thread.java:748)
 [Pipeline] }
 [Pipeline] // ws
 [Pipeline] }
 [Pipeline] // node
 [Pipeline] }
 [Pipeline] // stage
 [Pipeline] }
 Failed in branch Windows build

java.io.IOException: error=24, Too many open files

我正在使用 centos VM 作为 Jenkins 服务器,最近我遇到了这个问题 java.io.IOException: error=24, Too many open files,运行任何 Jenkins 作业都会失败。

  1. 在我的机器上运行ulimit -n默认值是1024
  2. 运行ulimit -n 4096以增加此值以4096解决我的问题

永久解决方案

使用您的 root 用户更改 etc/security/limits.conf 文件,如下所示:

jenkins      soft   nofile  4096
jenkins      hard   nofile  8192

解释

jenkins——用户/组名软/硬——链接类型。注意:软链接可以从 0 到硬链接。nofile -- 打开文件的数量以及它的值。

注销然后登录到您的 Jenkins 服务器并使用您的 ID 再次 jenkins 运行 ulimit -a 命令。

如果输出如下所示,恭喜,您的更改已经生效。

bash-4.2$ id
uid=990(jenkins) gid=984(jenkins) groups=984(jenkins)
bash-4.2$ ulimit -a

open files                      (-n) 4096

相关连接:https://stackoverflow.com/questions/46065008/too-many-open-files-error-cant-open-jenkins-after-installing-many-plugins

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

关于作者

错々过的事

暂无简介

文章
评论
26 人气
更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文