【问题标题】:Jenkins "Error cloning remote repo 'origin'" and "Cannot allocate memory"詹金斯“克隆远程仓库'origin'时出错”和“无法分配内存”
【发布时间】:2022-02-15 19:33:04
【问题描述】:

我在通过 webhook 与 GitHub 连接的服务器上运行 Jenkins。不幸的是,我的构建偶尔会失败,我不知道为什么。有时重新启动 Jenkins (sudo service jenkins restart) 可以解决问题,有时则不能。服务器运行 Ubuntu 16.04 nad Nginx 作为代理。是什么导致了这个问题,我该如何解决?

Started by GitHub push by gaboratorium
Building in workspace /var/lib/jenkins/workspace/kudos.gaboratorium.com
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Cloning the remote Git repository
Cloning repository https://github.com/gaboratorium/kudos.git
> git init /var/lib/jenkins/workspace/kudos.gaboratorium.com # timeout=10
Fetching upstream changes from https://github.com/gaboratorium/kudos.git
> git --version # timeout=10
> git fetch --tags --progress https://github.com/gaboratorium/kudos.git 
+refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress 
https://github.com/gaboratorium/kudos.git 
+refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: error: cannot fork() for fetch-pack: Cannot allocate memory

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1903)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1622)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$300(CliGitAPIImpl.java:71)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:348)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$2.execute(CliGitAPIImpl.java:545)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1070)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1110)
at hudson.scm.SCM.checkout(SCM.java:495)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1276)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:560)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:485)
at hudson.model.Run.execute(Run.java:1735)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:405)
ERROR: Error cloning remote repo 'origin'
Finished: FAILURE

【问题讨论】:

  • 这个错误怎么办:stderr: error: cannot fork() for fetch-pack: Cannot allocate memory?

标签: git ubuntu nginx github jenkins


【解决方案1】:

使用 df -hdu -sh $JENKINS_HOME 检查是否有足够的内存供 Jenkins 分配。

【讨论】:

  • 感谢您的回答!我已经运行了这些,但我不太确定我应该寻找什么。对我来说这似乎很好。截图:prntscr.com/frv2he
  • 您的磁盘上似乎有足够的空间。我认为你缺少内存。在这里试试这个ps --sort -rss -eo rss,pid,command | head。从这里偷askubuntu.com/questions/253466/….
  • 我只是尝试在服务器上以用户jenkins 的身份手动执行这些步骤,但没有出现任何错误。手动工作,但是当使用 webhook 触发 Jenkins 时,它会失败:(
【解决方案2】:

原来,这是一个 OOM(内存不足)问题,可以通过创建一些交换空间来轻松解决。为此,我遵循了本指南,它完美地解决了我的问题:https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04

另外,我自己也对设置做了一些说明。如果您遇到问题,您可能会发现它很有帮助:https://archives.gaboratorium.hu/continuous-integration-with-jenkins

【讨论】:

  • 感谢您分享解决方案!
猜你喜欢
  • 1970-01-01
  • 2016-11-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多