欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

解决Jenkins上git时出现“ERROR: Timeout after 10 minutes”的时间超时问题

程序员文章站 2022-03-16 21:09:53
环境:使用jenkins通过pipeline拉取github代码 最近在Jenkins上新建Job时,使用Pipeline流水线方式自动化发布项目报错具体如下: ERROR: Timeout after 10 minutes” ERROR: Error fetching remote repo 'o ......

环境:使用jenkins通过pipeline拉取github代码

最近在jenkins上新建job时,使用pipeline流水线方式自动化发布项目报错具体如下:

error: timeout after 10 minutes”

error: error fetching remote repo 'origin'

started by user liucx
building in workspace /opt/jenkins/workspace/****-uat
 > git rev-parse --is-inside-work-tree # timeout=10
fetching changes from the remote git repository
 > git config remote.origin.url {url} # timeout=10
fetching upstream changes from {url}
 > git --version # timeout=10
using git_askpass to set credentials
 > git fetch --tags --progress {url} +refs/heads/*:refs/remotes/origin/*
error: timeout after 10 minutes
error: error fetching remote repo 'origin'
hudson.plugins.git.gitexception: failed to fetch from {url}
    at hudson.plugins.git.gitscm.fetchfrom(gitscm.java:888)
    at hudson.plugins.git.gitscm.retrievechanges(gitscm.java:1155)
    at hudson.plugins.git.gitscm.checkout(gitscm.java:1186)
    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:1727)
    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 "git fetch --tags --progress {url} +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: counting objects: 62, done.       
remote: compressing objects:   4% (1/23)          
remote: compressing objects:   8% (2/23)          
remote: compressing objects:  13% (3/23)          
remote: compressing objects:  17% (4/23)          
remote: compressing objects:  21% (5/23)          
remote: compressing objects:  26% (6/23)          
remote: compressing objects:  30% (7/23)          
remote: compressing objects:  34% (8/23)          
remote: compressing objects:  39% (9/23)          
remote: compressing objects:  43% (10/23)          
remote: compressing objects:  47% (11/23)          
remote: compressing objects:  52% (12/23)          
remote: compressing objects:  56% (13/23)          
remote: compressing objects:  60% (14/23)          
remote: compressing objects:  65% (15/23)          
remote: compressing objects:  69% (16/23)          
remote: compressing objects:  73% (17/23)          
remote: compressing objects:  78% (18/23)          
remote: compressing objects:  82% (19/23)          
remote: compressing objects:  86% (20/23)          
remote: compressing objects:  91% (21/23)          
remote: compressing objects:  95% (22/23)          
remote: compressing objects: 100% (23/23)          
remote: compressing objects: 100% (23/23), done.       
error: unpack-objects died of signal 15
fatal: unpack-objects failed
 
    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 hudson.plugins.git.gitscm.fetchfrom(gitscm.java:886)
    ... 11 more
error: error fetching remote repo 'origin'
finished: failure
#https://www.cnblogs.com/liucx/

分析原因:

1.github属于国外网站,经常访问不稳定,一般需要*

2.代码仓库文件过大,请求超时

 

解决方式:

在pepeline脚本中的extensions(扩展插件)中添加设置timeout时间为30min,默认为10min,即可解决


stages { stage('拉取源码') { steps { checkout([ //详情看https://www.cnblogs.com/liucx/
$class: 'gitscm', branches: [[name: "${branch}"]], dogeneratesubmoduleconfigurations: false,extensions: [[$class:'checkoutoption',timeout:30],[$class:'cloneoption',depth:0,notags:false,reference:'',shallow:false,timeout:30]], submodulecfg: [], userremoteconfigs: [[credentialsid: 'github', url: "${project_url}"]] ]) } }

 或者使用下面设置方式设置时间超时

解决Jenkins上git时出现“ERROR: Timeout after 10 minutes”的时间超时问题