Jenkins无法从远程git获取代码

nis*_*hat 34 git jenkins

我的jenkins构建现在突然不起作用了.错误如下: -

Fetching changes from the remote Git repository
 > git config remote.origin.url <url> # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from <url>
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:735)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:983)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1016)
    at hudson.scm.SCM.checkout(SCM.java:484)
    at hudson.model.AbstractProject.checkout(AbstractProject.java:1270)
    at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:622)
    at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:528)
    at hudson.model.Run.execute(Run.java:1759)
    at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:529)
    at hudson.model.ResourceController.execute(ResourceController.java:89)
    at hudson.model.Executor.run(Executor.java:240)
Caused by: hudson.plugins.git.GitException: Command "git config remote.origin.url <url> returned status code 4:
stdout: 
stderr: error: failed to write new configuration file .git/config.lock
Run Code Online (Sandbox Code Playgroud)

我无法找出根本原因.我已经检查了jenkins主文件夹的权限和所有权,这是/ var/lib/jenkins: - drwxrwxrwx 17 jenkins jenkins 4096 Jun 25 04:30 jenkins

jenkins工作区文件夹中.git文件夹的权限和所有权是: - drwxrwxrwx 8 jenkins jenkins 4096 Jun 30 21:51 .git

请指导我解决问题.

the*_*ina 23

当Jenkins VM磁盘空间不足时经验丰富.清理它,不再看到这个问题了.


小智 16

我看到了同样的问题,但磁盘空间和VM内存不是问题.为我修复它的原因是在构建时重新克隆作业:

  1. 转到作业的"配置"页面
  2. 在源代码管理→Git→附加行为下,添加行为"擦除存储库和强制克隆"
  3. 保存
  4. 建立

  • 或者在使用管道时在管道脚本中添加 cleanWs()。 (2认同)

Joh*_*ny5 8

尝试清除工作区文件并重建.


cnm*_*muc 8

就我而言,获取/下载远程代码非常慢,并且由于超时而中止。因此,我将“克隆和获取操作的超时(以分钟为单位)”增加到 20 分钟。

在此处输入图片说明