詹金斯"Error cloning remote repo 'origin'"和"Cannot allocate memory"



我让 Jenkins 在我的服务器上运行,通过 webhooks 与 GitHub 连接。不幸的是,我的构建偶尔会失败,我不知道为什么。有时重新启动 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

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

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

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

最新更新