Jenkins与Grunt集成 [英] Jenkins integration with Grunt

查看:648
本文介绍了Jenkins与Grunt集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows Server 2008 R2上安装了Jenkins v1.550。它现在在 http:// localhost:8080 中作为服务运行。我以管理员身份登录到计算机。我已经安装了Node.js,并且可以从命令行运行npm。



我还为Jenkins安装了NodeJS插件v0.2.1。然后进入Jenkins的配置系统部分,向下滚动到NodeJS安装,单击Add NodeJS按钮,给出NodeJS作为名称,C:\ Program Files \ node_name作为安装目录的路径。我没有检查自动安装选项,因为我在插件页面上阅读它只能在Linux上使用。然后我创建了一个新的作业,点击了提供节点和npm bin /文件夹到PATH复选框,为执行Windows批处理创建了一个新的构建步骤命令并输入node --version和grunt --version并保存。



我运行了这个作业,这是输出 -

 在工作区C:\ Program Files(x86)\Jenkins\workspace\Test_1.0 
[Test_1 .0] $ cmd / c call C:\Windows\TEMP\hudson1381541243088903083.bat

C:\程序文件(x86)\Jenkins\workspace\Test_1.0> node --version
v0.10.24

C:\ Program Files(x86)\Jenkins\workspace\Test_1.0> grunt --version
'grunt '不被识别为内部或外部命令,
可操作程序或批处理文件。

C:\程序文件(x86)\Jenkins\workspace\Test_1.0>退出9009
构建步骤'执行Windows批处理命令'标记为失败
完成:FAILURE

看起来它无法找到用户帐户的grunt-cli Jenkins在(系统)下运行。我尝试在全局安装grunt cli( npm install -g grunt-cli )并且在本地安装grunt( npm install grunt )。



有人可以帮忙吗?

轻松配置机器上自行安装的nodejs,我不得不推荐极好 - > http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin



它会通过简单的方式在机器上安装nodejs和grunt使用web前端不需要shell

jenkins jobs然后可以简单地运行nodejs构建步骤,嘿presto

涉及的步骤:
$ b $ a)将这个安装在你的jenkins实例上 - > http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin



创建在jenkins上安装nodejs



转至

  http:// URL_OF_JENKINS / jenkins / configure 




  • NodeJS-> NodeJS安装 - >添加NodeJS - > Name =NodeJS 0.11.10,勾选自动安装,选择从nodejs.org安装,为全局安装的软件包添加grunt-cli


c)使用执行NodeJS脚本构建任务创建作业

  var sys = require('sys'); 
sys.puts('NodeJS Test');
sys.puts('***************');
sys.puts('helloworld');

volia:)

运行作业并查看nodejs脚本运行,从它们的世界中获取

是您的牡蛎,您可以通过勾选提供Node / npm bin文件夹到PATH来运行grunt并运行execute shell构建任务

  npm update 
grunt
grunt --force报告

code>


I've setup Jenkins v1.550 on Windows Server 2008 R2. It runs as a service at http://localhost:8080 for now. I'm logged into the machine as an Administrator. I've installed Node.js and can run "npm" from the command line.

I've also installed the NodeJS plugin v0.2.1 for Jenkins. I then went into the Configure System section of Jenkins, scrolled down to NodeJS installations, clicked on Add NodeJS button, gave "NodeJS" as the name, and "C:\Program Files\nodejs" as the path to the installation directory. I didn't check the "Install automatically" option as I read on the plugin page that it is only available to Linux.

I then created a new job, clicked the checkbox that said "Provide Node & npm bin/ folder to PATH", created a new build step for "Execute Windows batch command" and typed in "node --version" and "grunt --version" and saved it.

I ran the job and this is the output -

Building in workspace C:\Program Files (x86)\Jenkins\workspace\Test_1.0
[Test_1.0] $ cmd /c call C:\Windows\TEMP\hudson1381541243088903083.bat

C:\Program Files (x86)\Jenkins\workspace\Test_1.0>node --version 
v0.10.24

C:\Program Files (x86)\Jenkins\workspace\Test_1.0>grunt --version 
'grunt' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files (x86)\Jenkins\workspace\Test_1.0>exit 9009 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

It looks like it's unable to find the grunt-cli for the user account Jenkins is running under (System). I tried to installing grunt cli globally (npm install -g grunt-cli) and also grunt locally (npm install grunt). No luck.

Can someone please help?

解决方案

for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

it will install nodejs and grunt on the machine, through easy to use web front end no shell required

jenkins jobs can then simply run nodejs build steps, hey presto

steps involved :

a) install this on your jenkins instance -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin

b) create a nodejs installation on jenkins

go to

http://URL_OF_JENKINS/jenkins/configure

  • NodeJS- > NodeJS installations -> Add NodeJS -> Name = "NodeJS 0.11.10", tick "Install automatically", select "Install from nodejs.org", add "grunt-cli" to globally installed packages

c) create a job with "execute NodeJS script" build task

var sys = require('sys');
sys.puts('NodeJS Test');
sys.puts('***************');
sys.puts('helloworld');

volia :)

run the job and see the nodejs script run,

from their the world is your oyster you can use grunt by ticking "Provide Node/npm bin folder to PATH" and running a "execute shell" build task

npm update
grunt
grunt --force reporting

这篇关于Jenkins与Grunt集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆