我正试图在Jenkins中构建并运行一个基于grunt的构建任务,该任务是用yeoman生成器创建的。
Jenkins能够成功地运行npm install
和bower install
。
问题:当我运行grunt
时,Jenkins崩溃了:无法通过浏览器访问它,它丢失了构建任务的条目,必须重新启动它。
如果我在任务运行时观察控制台输出,那么在服务器崩溃之前我得到的最后一条消息是:
[4mRunning "concurrent:dist" (concurrent) task[24m [32m>>
[39mWarning: There are more tasks than your concurrency limit. After
this limit[32m
>> [39mis reached no further tasks will be run until the current tasksare[32m
>> [39mcompleted. You can adjust the limit in the concurrent task options
到目前为止我尝试了什么:
- 我尝试将Jenkins设置为允许4个构建过程
- 我还试图将其限制为1个构建过程。两者都没有改变任何事情
- 我真的无法改变繁重的任务,因为我必须在30多个项目中完成它
问题:有没有一种方法可以在不崩溃的情况下运行并发的咕哝任务?
Gruntfile.js的一部分:
// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'compass:server'
],
test: [
'compass'
],
dist: [
'compass:dist',
'imagemin',
'svgmin'
]
},
尽管adben的答案是对的,但他没有解释在哪里设置limit
。它在你的Gruntfile中,这就是它应该如何寻找一个有两个并发任务的例子:
grunt.initConfig({
concurrent: {
target: {
tasks: [ 'watch', 'nodemon:run' ],
options: {
limit: 2,
logConcurrentOutput: true
}
},
}
});
以下是grunt并发的文档
您可以声明要使用的CPU核数,即:
options:
limit: 2
logConcurrentOutput: true