前两天在使用Jenkins自动化构建的时候,拉取代码就报错,说有个文件是空的,找了很久终于找到了解决方案,网上很少有相关的资料,这里给大家分享一下。

报错信息如下

hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --prune -- origin +refs/heads/dev:refs/remotes/origin/dev" returned status code 128:
stdout: 
stderr: error: object file .git/objects/c3/a2479ddf76c2a91ff9d4424f5bdef38fc1142c is empty
error: object file .git/objects/c3/a2479ddf76c2a91ff9d4424f5bdef38fc1142c is empty
fatal: loose object c3a2479ddf76c2a91ff9d4424f5bdef38fc1142c (stored in .git/objects/c3/a2479ddf76c2a91ff9d4424f5bdef38fc1142c) is corrupt
fatal: the remote end hung up unexpectedly

	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2671)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2096)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$500(CliGitAPIImpl.java:84)
	at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:618)
	at jenkins.plugins.git.GitSCMFileSystem$BuilderImpl.build(GitSCMFileSystem.java:366)
	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:197)
	at jenkins.scm.api.SCMFileSystem.of(SCMFileSystem.java:173)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:118)
	at org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition.create(CpsScmFlowDefinition.java:70)
	at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:311)
	at hudson.model.ResourceController.execute(ResourceController.java:101)
	at hudson.model.Executor.run(Executor.java:442)
Finished: FAILURE

处理方案:找到Jenkins工作目录,删除caches文件夹内的所有内容

cd /var/jenkins_home/caches
rm -rf ./*

注意:Jenkins工作目录可能会不一样,需要自己找一下

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐