【发布时间】:2018-04-29 08:25:58
【问题描述】:
不过,我真的很想让 yarn 与 TeamCity 或 Jenkins 合作
yarn install 消耗了我所有构建服务器的 CPU 和内存,即使使用
一个很小的 npm 项目。知道为什么吗?
总结
-
yarn install,当由 TeamCity 或 Jenkins 运行时,会消耗大部分 CPU/内存,永远不会完成 - 在构建服务器上从命令行运行
yarn install可以正常工作(几秒钟后完成) -
npm install在由 TeamCity/Jenkins 运行时在几秒钟内完成 - 构建服务器:Windows Server 2012,2 核,4GB 内存
- 纱线版本 1.6.0
- Jenkins 版本 2.107.2
- TeamCity 版本 2017.2.3
- 已试用 Node.js 版本 8.11.1 和 9.11.1
详情
步骤:
创建一个小型 npm 项目:
mkdir temp
cd temp
yarn init # all defaults
yarn add dummy-module # tiny test package
将此提交给 git,使用单个命令 yarn install 设置 Jenkins 或 TeamCity 构建。
构建永远不会完成,控制台输出的最后一行是:yarn install v1.6.0。
此时,Node.js 进程正在消耗大部分 CPU 和内存
造机器。将命令更改为npm install 使其运行成功。
由于 Jenkins 和 TeamCity 很常见,因此问题似乎与 从java运行子进程。我找不到任何迹象表明出了什么问题 在 TeamCity 或 Jenkins 日志中。中止 Jenkins 构建时, 我在 jenkins.err.log 中看到以下内容:
Apr 22, 2018 8:59:11 AM hudson.model.Run execute
INFO: master-cake #9 aborted
java.lang.InterruptedException
at java.lang.ProcessImpl.waitFor(Unknown Source)
at hudson.Proc$LocalProc.join(Proc.java:324)
at hudson.tasks.CommandInterpreter.join(CommandInterpreter.java:155)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:744)
at hudson.model.Build$BuildExecution.build(Build.java:206)
at hudson.model.Build$BuildExecution.doRun(Build.java:163)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
at hudson.model.Run.execute(Run.java:1727)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:97)
at hudson.model.Executor.run(Executor.java:429)
【问题讨论】:
-
您需要隔离 CI 服务器并构建代理。好的。对于您的问题,您需要隔离纱线过程。捷径 - 码头工人。你可以在你的服务器上使用 docker 吗?
-
并尝试通过
--max-old-space-size=2048 -
@SeniorPomidor 很遗憾不能使用 docker。我尝试了 --max-old-space-size 的大小范围,结果与上述相同
标签: node.js jenkins npm teamcity yarnpkg