环境:使用jenkins通过pipeline拉取github代码
最近在Jenkins上新建Job时,使用Pipeline script 流水线方式实现自动化发布项目报:
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}"]] ]) } }