坦白背景
主要看到的报错内容是这一块
error: index-pack died of signal 15 11:18:19 fatal: index-pack failed 11:18:19 11:18:19 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2174) 11:18:19 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1866) 11:18:19 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:78) 11:18:19 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:547) 11:18:19 at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:760) 11:18:19 at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1152) 11:18:19 at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1192) 11:18:19 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:124) 11:18:19 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:93) 11:18:19 at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:80) 11:18:19 at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47) 11:18:19 at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 11:18:19 at java.util.concurrent.FutureTask.run(FutureTask.java:266) 11:18:19 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) 11:18:19 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) 11:18:19 at java.lang.Thread.run(Thread.java:748) 11:18:19 [Pipeline] } 11:18:19 [Pipeline] // stage 11:18:19 [Pipeline] stage 11:18:19 [Pipeline] { (Deploy) 11:18:19 Stage "Deploy" skipped due to earlier failure(s) 11:18:19 [Pipeline] } 11:18:19 [Pipeline] // stage 11:18:19 [Pipeline] } 11:18:19 ERROR: Error cloning remote repo 'origin'
其实往上面翻一翻就可以看到精准的报错,是 clone 仓库的时候超时导致的
11:18:19 ERROR: Timeout after 10 minutes 11:18:19 ERROR: Error cloning remote repo 'origin'
去 gitlab 查看,发现这个仓库有 1.8G 那么大,git 和 jenkins 不在同一个公有云,带宽(只有1MB,实际均值在 500KiB/s)的限制,导致 10分钟根本拉不完
解决方案
方案一
让开发整理自己的 git 仓库,把仓库缩小
方案二
增加超时时间
pipeline - checkout scm
增加
extensions: [[$class: 'CloneOption', timeout: 60]]
指定超时时间,单位是分钟,默认是 10分钟
checkout scm: [$class: 'GitSCM', extensions: [[$class: 'CloneOption', timeout: 60]], userRemoteConfigs: [[credentialsId: 'deploy', url: "${GIT_URL}"]], branches: [[name: "${GIT_BRANCH}"]]], poll: false
页面配置
- jenkins项目 -> 配置(configure) -> git -> Additional Behaviours -> add -> advanced clone behaviours