jenkins clone代码超时 imeout after 10 minutes

本文详细介绍了在Jenkins中遇到从GitLab拉取代码超时的问题及解决方案。通过编辑Jenkins项目配置,增加克隆和拉取操作的超时时间,可以有效解决这一常见错误。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ERROR: Timeout after 10 minutes
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from git@gitlab.gaoxiaobang.com:huikeyun/huikeyun-teacher-android.git
	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:894)
	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1161)
	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192)
	at org.jenkinsci.plugins.multiplescms.MultiSCM.checkout(MultiSCM.java:143)
	at hudson.scm.SCM.checkout(SCM.java:504)
	at hudson.model.AbstractProject.checkout(AbstractProject.java:1208)
	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:574)
	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:499)
	at hudson.model.Run.execute(Run.java:1818)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: hudson.plugins.git.GitException: Command "F:\install\Git\cmd\git.exe fetch --tags --progress git@gitlab.gaoxiaobang.com:huikeyun/huikeyun-teacher-android.git +refs/heads/*:refs/remotes/origin/*" returned status code -1073741510:

超时

解决方案

Solution steps:

For resolve the problem we have to edit in Jenkins project configuration and find the "git".
Then click on "Add" button and select "Advanced clone behaviours".
Then in Timeout (in minutes) for clone and fetch operations box put any number which is more then 10, (I put 60 here).
Apply and the save the configuration.
Build Now again , It took some more time to build , but it will fixed this error.

### 解决 Jenkins Git 拉取代码超时问题 当遇到 Jenkins 从 Git 仓库拉取代码时出现的超时问题,可以采取多种措施来优化这一过程并解决问题。 #### 增加 Git 超时设置 为了防止由于网络延迟或其他因素引起的克隆失败,可以在 Jenkins 的配置文件 `config.xml` 中增加 git timeout 参数。这可以通过编辑全局配置或特定作业中的 SCM 设置实现。对于大型项目而言,默认的超时时间可能不足以完成整个 `.git` 文件夹的下载[^1]。 ```xml <scm class="hudson.plugins.git.GitSCM"> ... <extensions> <org.jenkinsci.plugins.gitclient.TimeoutExtension> <timeout>60</timeout> <!-- 单位为秒 --> </org.jenkinsci.plugins.gitclient.TimeoutExtension> </extensions> ... </scm> ``` #### 使用 SSH 进行连接 如果当前使用的是 HTTPS 方式访问 GitHub,则考虑切换至更稳定的 SSH 连接方式。SSH 不仅提供了更好的安全性,而且还可以减少因证书验证而导致的时间消耗。确保本地已经正确设置了 SSH 密钥,并将其添加到了对应的 Git 托管平台上[^2]。 #### 启用浅拷贝(Shallow Clone) 启用浅拷贝功能可以让 Jenkins 只获取最近的历史记录而不是完整的版本库历史,从而加快速度并降低带宽占用。此选项同样是在 Jenkins Job Configuration 页面下的 Source Code Management -> Additional Behaviours 添加 Shallow clone with depth 来设定深度值。 ```groovy pipeline { agent any stages { stage('Checkout') { steps { checkout([$class: 'GitSCM', branches: [[name: '*/main']], extensions: [[$class: 'CloneOption', noTags: true, reference: '', shallow: true]], userRemoteConfigs: [[url: 'https://github.com/your-repo-url']] ]) } } } } ``` #### WebHook 触发机制调整 确保 PyCharm 和其他开发工具与 Git 正常集成的同时,也应检查 Jenkins 上 webhooks 是否正常工作。有时候频繁触发可能导致资源竞争进而引发超时错误。适当调整 webhook 发送频率或者采用轮询策略作为补充手段也是可行的方法之一[^3]。 通过上述方法的应用,应该能够有效缓解甚至彻底解决 Jenkins 在处理大规模 Git 库时所面临的超时难题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

安果移不动

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值