【Git】【Jenkins】ERROR: Error fetching remote repo ‘origin‘

本文介绍了在使用Jenkins从Git仓库拉取代码时遇到的ERROR: Error fetching remote repo 'origin'错误。错误原因是shallow.lock文件存在,解决方案是删除该文件并重新拉取代码。

Description

Jenkins 拉取git 仓库代码报错:ERROR: Error fetching remote repo 'origin'

  • 相关报错

    +refs/pull/*:refs/remotes/origin/pr/* --depth=1 # timeout=60
    22:29:14 ERROR: Error fetching remote repo 'origin'
    22:29:14 hudson.plugins.git.GitException: Failed to fetch from <https://github.com/xxxxxx/ppppp.git>
    22:29:14 	at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:888)
    22:29:14 	at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1155)
    22:29:14 	at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1186)
    22:29:14 	at hudson.scm.SCM.checkout(SCM.java:505)
    22:29:14 	at hudson.model.AbstractProject.checkout(AbstractProject.java:1206)
    22:29:14 	at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:637)
    22:29:14 	at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    22:29:14 	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:509)
    22:29:14 	at hudson.model.Run.execute(Run.java:1907)
    22:29:14 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    22:29:14 	at hudson.model.ResourceController.execute(ResourceController.java:97)
    22:29:14 	at hudson.model.Executor.run(Executor.java:429)
    22:29:14 Caused by: hudson.plugins.git.GitException: Command "git fetch --no-tags --progress <https://github.com/xxxxxx/pppppp.git> +refs/pull/*:refs/remotes/origin/pr/* --depth=1" returned status code 128:
    22:29:14 stdout: 
    22:29:14 stderr: fatal: unable to get credential storage lock: File exists
    22:29:14 fatal: Unable to create '/opt/jenkins/workspace/pppppp-PR-Check/.git/shallow.lock': File exists.
    22:29:14 
    

Root Cause

对应的报错当中已经有所提示了,提示 shallow.lock 文件已经存在

fatal: Unable to create '/opt/jenkins/workspace/ppppp-PR-Check/.git/shallow.lock': File exists.

Solutions

找到 shallow.lock 文件进行删除即可,并重新拉取最新代码

Related

对于 shallow.lock 的相关解释

This is because when the shallow lock is committed, the stat information
of the shallow file is not cleared. Ensure that this information is
always cleared whenever the shallow lock is committed by introducing a
new API that hides the shallow lock behind a custom struct.
Started by user zhaoshihao Running as SYSTEM Building in workspace C:\ProgramData\Jenkins\.jenkins\workspace\jj The recommended git tool is: NONE No credentials specified > git.exe rev-parse --resolve-git-dir C:\ProgramData\Jenkins\.jenkins\workspace\jj\.git # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url git@gitee.com:qwerrain/jx.git # timeout=10 Fetching upstream changes from git@gitee.com:qwerrain/jx.git > git.exe --version # timeout=10 > git --version # 'git version 2.49.0.windows.1' > git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/* # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from git@gitee.com:qwerrain/jx.git at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999) at PluginClassLoader for git//hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1240) at PluginClassLoader for git//hudson.plugins.git.GitSCM._checkout(GitSCM.java:1311) at PluginClassLoader for git//hudson.plugins.git.GitSCM.checkout(GitSCM.java:1278) at hudson.scm.SCM.checkout(SCM.java:540) at hudson.model.AbstractProject.checkout(AbstractProject.java:1250) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:649) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:85) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:522) at hudson.model.Run.execute(Run.java:1833) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:44) at hudson.model.ResourceController.execute(ResourceController.java:101) at hudson.model.Executor.run(Executor.java:446) Caused by: hudson.plugins.git.GitException: Command "git.exe fetch --tags --force --progress -- git@gitee.com:qwerrain/jx.git +refs/heads/*:refs/remotes/origin/*" returned status code 128: stdout: stderr: Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2852) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2188) at PluginClassLoader for git-client//org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:638) at PluginClassLoader for git//hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997) ... 12 more ERROR: Error fetching remote repo 'origin' Finished: FAILURE
10-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值