環境:使用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}"]] ]) } }
或者使用下麵設置方式設置時間超時