jenkins git can't work ERROR: Timeout after 10 minutes ERROR: Error fetching remote repo 'origin'

本文记录了一次使用 Jenkins 进行 Git 仓库拉取时出现超时及错误的问题解决过程。通过调整 Git 版本,成功解决了 Jenkins 在特定环境下无法正常获取 Git 仓库的难题。

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

Started by user Allen
Running as Allen
Building remotely on MISTestSrv2 (MIS) in workspace C:\jenkins_slave\workspace\MIS-WebPrint-Source\MIS-TEST-Uniqlo-Source
 > C:\Program Files (x86)\Git\bin\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > C:\Program Files (x86)\Git\bin\git.exe config remote.origin.url http://192.168.22.103:3000/WebPrint/Uniqlo.git # timeout=10
Fetching upstream changes from http://192.168.22.103:3000/WebPrint/Uniqlo.git
 > C:\Program Files (x86)\Git\bin\git.exe --version # timeout=10
using GIT_ASKPASS to set credentials gogs readonly
 > C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress http://192.168.22.103:3000/WebPrint/Uniqlo.git +refs/heads/*:refs/remotes/origin/*
ERROR: ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from http://192.168.22.103:3000/WebPrint/Uniqlo.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:806)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1101)
    at hudson.scm.SCM.checkout(SCM.java:496)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1280)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529)
    at hudson.model.Run.execute(Run.java:1735)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:97)
    at hudson.model.Executor.run(Executor.java:405)
Caused by: hudson.plugins.git.GitException: Command "C:\Program Files (x86)\Git\bin\git.exe fetch --tags --progress http://192.168.22.103:3000/WebPrint/Uniqlo.git +refs/heads/*:refs/remotes/origin/*" returned status code -1:
stdout: 
stderr: 
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1799)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1525)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:65)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:316)
    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:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:336)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    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 hudson.remoting.Engine$1$1.run(Engine.java:94)
    at java.lang.Thread.run(Unknown Source)
    at ......remote call to JNLP4-connect connection from demosrv03.xxxxx.local/192.168.42.3:61780(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:830)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.execute(RemoteGitImpl.java:146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.jenkinsci.plugins.gitclient.RemoteGitImpl$CommandInvocationHandler.invoke(RemoteGitImpl.java:132)
    at com.sun.proxy.$Proxy61.execute(Unknown Source)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:804)
    ... 11 more
ERROR: null
Timeout after 10 minutes
Sending e-mails to: Allen@xxxxx.com.cn
Finished: FAILURE

这个错误很奇怪,刚开始我以为是jenkins主机与从机,jenkins与git之间的权限问题,经过一番排查和从头到尾重新设置一遍,以及重启Jenkins主机,Jenkins从机,程序发布目标机器。

重新运行Job依旧得到这个错误。

然后我开始求度娘,爬谷哥,无解。

其中我找到一个最接近我这个错误的博文--http://blog.youkuaiyun.com/njafei/article/details/50681106,但也没效果。

 

后来,我仔细回想了一下,以前用Git-2.11.0-32-bit.exe没问题,后来迁移新服务器后用Git-2.12.2-32-bit.exe版本安装就开始出问题。

于是,我尝试卸载2.12.2版本,装回2.11.0版本,问题解决。

我的Jenkins版本是Jenkins ver. 2.53

插件:Git client plugin : 2.4.1

        Git plugin : 3.2.0

 

转载于:https://www.cnblogs.com/VAllen/p/Jenkins-Error-Timeout-And-Fetching.html

Started by user admin Running as SYSTEM Building in workspace /var/lib/jenkins/workspace/mav-test The recommended git tool is: NONE using credential 947311a0-1669-4d11-9146-fbbe7d6a3489 > git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/mav-test/.git # timeout=10 Fetching changes from the remote Git repository > git config remote.origin.url git@10.0.0.13:gitlab-instance-ea96ef19/mav-test.git # timeout=10 Fetching upstream changes from git@10.0.0.13:gitlab-instance-ea96ef19/mav-test.git > git --version # timeout=10 > git --version # 'git version 1.8.3.1' using GIT_SSH to set credentials Verifying host key using known hosts file > git fetch --tags --progress git@10.0.0.13:gitlab-instance-ea96ef19/mav-test.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@10.0.0.13:gitlab-instance-ea96ef19/mav-test.git at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1239) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1310) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1277) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1247) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:521) at hudson.model.Run.execute(Run.java:1894) at PluginClassLoader for maven-plugin//hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:543) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:446) Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@10.0.0.13:gitlab-instance-ea96ef19/mav-test.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: No ECDSA host key is known for 10.0.0.13 and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635) at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:995) ... 12 more ERROR: Error fetching remote repo 'origin' Finished: FAILURE
最新发布
07-18
Started by user Fly Running as SYSTEM Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\ZrLog项目 The recommended git tool is: NONE using credential ca305872-f337-4105-ba2c-b97a40bbfb4e > git.exe rev-parse --resolve-git-dir C:\ProgramData\Jenkins\.jenkins\workspace\ZrLog项目\.git # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url git@gitee.com:hu-jia-san-shao/zr-log.git # timeout=10 Fetching upstream changes from git@gitee.com:hu-jia-san-shao/zr-log.git > git.exe --version # timeout=10 > git --version # 'git version 2.48.1.windows.1' using GIT_SSH to set credentials Verifying host key using known hosts file You're using 'Known hosts file' strategy to verify ssh host keys, but your known_hosts file does not exist, please go to 'Manage Jenkins' -> 'Security' -> 'Git Host Key Verification Configuration' and configure host key verification. > git.exe fetch --tags --force --progress -- git@gitee.com:hu-jia-san-shao/zr-log.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@gitee.com:hu-jia-san-shao/zr-log.git at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1240) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1311) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1278) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1250) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522) at hudson.model.Run.execute(Run.java:1833) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hud
03-12
Fetching upstream changes from git@github. com:a792883583/treeHoleScore.git > /usr/bin/git --version # timeout=10 > git --version # 'git version 1.8.3.1' using GIT _ASKPASS to set credentials github > /usr/bin/git fetch --tags --progress git@github. com:a792883583/treeHoleScore.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson. plugins.git.GitException: Failed to fetch from git@github. com:a792883583/treeHoleScore.git at hudson. plugins . git .GitSCM. fetchFrom(GitSCM. java:1003) at hudson. plugins .git .GitSCM. retrieveChanges(GitSCM. java:1245) at hudson.plugins.git.GitsCM. checkout(GitSCM. java:1309) at hudson.scm. SCM. checkout(SCM. java:540) at hudson. mode1. AbstractProject . checkout(AbstractProject . java:1240) at hudson. model AbstractBuild$AbstractBuildExecution. def aultCheckout (AbstractBuild. java:649) at jenkins .scm. SCMCheckoutStrategy . checkout(SCMCheckoutStrategy . java:85) at hudson . model. AbstractBuild$AbstractBuildExecution. run(AbstractBuild. java:521) at hudson.model . Run. execute(Run. java:1900) at hudson.model. FreeSty1eBuild.run(FreeStyleBuild.java:44) at hudson. model. ResourceController . execute(ResourceController . java:101) at hudson. model. Executor .run(Executor. java:442) Caused by: hudson. plugins.git .GitException: Command "/usr/bin/git fetch --tags --progress git@github . com: a792883583/treeHoleScore.git +refs/heads/* :refs/remotes/origin/*" returned status code 128: stdout: stderr: Host key verification failed. 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 .CliGitAPIImp1.1aunchCommandIn(CliGitAPImp1.java:2734) at org.jenkinsci .plugins.gitclient .CliGitAPIImp1.1aunchCommandWithCredentials(CliGitAPIImpl.java:2111) at org.jenkinsci.plugins . gitclient .CliGitAPIImp1$1. execute(CliGitAPIImp1.java:623) at hudson.p1ugins . git .GitSCM. fetchFrom (GitSCM. java:1001) 11 more ERROR: Error fetching remote repo ' origin' Finished: FAILURE
02-08
<think>我们正在处理用户关于Jenkins脚本超时错误的问题。用户提到脚本在10分钟后超时,需要解决方案。根据Jenkins的常见问题,脚本超时通常是由于Jenkins的默认脚本超时设置造成的。Jenkins默认对Groovy脚本执行有时间限制(通常为10分钟),超过这个时间就会抛出超时异常。解决方案通常有两种:1.在Jenkins系统配置中增加全局的脚本超时时间。2.在脚本中使用`setTimeout`方法为特定脚本设置更长的超时时间。另外,用户的问题可能是在执行一个长时间运行的Groovy脚本(例如在流水线中使用了`script`块,或者直接执行系统Groovy脚本)。我们还可以考虑是否有其他因素导致超时,例如网络问题、资源不足等,但用户明确提到了10分钟超时,这很符合Jenkins的默认设置。因此,我们将重点放在修改超时设置上。注意:用户要求的是解决方案,因此我们需要给出具体的操作步骤。参考引用中提到了Jenkins和Docker、AWS无服务器环境等,但用户当前问题与超时相关,所以这些引用可能不是直接相关的。不过,如果用户的超时发生在Docker构建或AWS无服务器部署中,我们可能需要考虑额外的环境因素。但是,用户的问题描述很明确:Jenkins脚本超时10分钟。所以我们先解决这个核心问题。步骤:方法一:通过Jenkins系统管理修改全局超时1.登录Jenkins,进入“ManageJenkins”(管理Jenkins)。2.选择“ConfigureSystem”(系统配置)。3.找到“GroovyScriptTimeout”(Groovy脚本超时)选项(可能在最后部分)。4.默认值可能是10(单位是分钟),可以将其增加,比如设置为60(分钟)。也可以设置为0表示无超时(不推荐,有风险)。5.保存设置。方法二:在脚本中设置超时(推荐,更灵活)在Groovy脚本中,可以使用`setTimeout`方法来设置该脚本的超时时间。例如:```groovy//设置超时为60分钟deftimeoutInMinutes=60setTimeout(timeoutInMinutes)//或者设置超时为毫秒//setTimeout(timeoutInMinutes*60*1000)//这里是你的长时间运行的脚本代码```但是注意:在流水线脚本中,我们通常使用`script`块来执行Groovy代码。在流水线中,我们可以这样设置超时:对于声明式流水线,可以使用`options`指令设置超时:```groovypipeline{agentanyoptions{timeout(time:60,unit:'MINUTES')//设置整个流水线的超时}stages{stage('Example'){steps{script{//你的长时间运行的Groovy脚本}}}}}```如果只是针对某个步骤,可以使用`timeout`步骤:```groovystage('LongRunning'){steps{timeout(time:60,unit:'MINUTES'){script{//长时间运行的代码}}}}```注意:这里设置的是步骤的超时,而不是Groovy脚本引擎的超时。但是,如果超时发生在Groovy脚本执行(例如系统Groovy脚本),那么第一种方法(系统设置)或者使用`setTimeout`可能更直接。用户的问题描述是“Jenkinsscripttimeouterror”,所以我们需要明确用户使用的是哪种脚本:-如果是系统Groovy脚本(例如通过“脚本控制台”执行),那么使用方法一或方法二中的`setTimeout`。-如果是流水线中的`script`块,那么使用方法二中的流水线超时设置。因此,我们可能需要用户提供更多上下文,但我们可以提供两种场景的解决方案。另外,如果用户使用的是Jenkinsfile,那么修改系统配置可能不是最佳选择(因为会影响所有作业),而推荐在流水线中设置超时。总结回答:我们将提供两种解决方案,并说明适用场景。同时,生成相关问题,以帮助用户深入理解或解决可能的相关问题。</think>### Jenkins脚本超时错误解决方案 Jenkins脚本在10分钟后超时通常是由于**Groovy脚本执行时间限制**导致的。以下是具体解决方案: #### ✅ 解决方案1:修改系统全局超时设置 1. 进入 **Jenkins管理后台** → **系统设置** 2. 找到 `Groovy Script Timeout` 配置项(通常在页面底部) 3. 将默认值 `10`(分钟)修改为更高值(如 `60`) 4. 保存设置并重启Jenkins ```groovy // 修改前默认配置 System.setProperty("org.codehaus.groovy.runtime.callsite.CallSite.MAX_CALL_RECURSION", "1000") ``` #### ✅ 解决方案2:在脚本中动态设置超时 在Pipeline脚本中使用`timeout`指令: ```groovy pipeline { agent any stages { stage('Long Task') { options { timeout(time: 60, unit: 'MINUTES') // 设置60分钟超时 } steps { script { // 你的长时间运行代码 sh './long_running_script.sh' } } } } } ``` #### ✅ 解决方案3:针对脚本控制台的临时调整 在 **脚本控制台** 执行时添加超时参数: ```groovy import hudson.util.Timeout2 Timeout2.defaultTimeout = 3600 // 单位:秒(3600秒=60分钟) // 你的Groovy脚本代码 ``` #### ✅ 解决方案4:优化脚本性能(预防性措施) - 将大任务拆分为多个阶段 - 避免在Groovy中处理大文件(改用Shell) - 增加Jenkins Master/JVM内存: ```bash # 修改Jenkins启动参数 JAVA_OPTS="-Xmx4g -XX:MaxPermSize=512m" ``` - 使用并行执行加速任务: ```groovy parallel( "Task1": { build('job1') }, "Task2": { build('job2') } ) ``` ### 根本原因分析 Jenkins默认限制Groovy脚本执行时间为10分钟,这是为了防止[脚本无限循环消耗系统资源](^1)。当脚本涉及以下操作时易触发: 1. 大型文件处理 2. 复杂数据结构遍历 3. 外部服务同步调用 4. 未优化的递归操作 > **注意**:若在Docker环境中运行,需同时检查容器资源限制(如`--ulimit`参数)[^2]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值