Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
387 views
in Technique[技术] by (71.8m points)

node.js - Jenkins integration with Grunt

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 odejs" 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)JenkinsworkspaceTest_1.0
[Test_1.0] $ cmd /c call C:WindowsTEMPhudson1381541243088903083.bat

C:Program Files (x86)JenkinsworkspaceTest_1.0>node --version 
v0.10.24

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

C:Program Files (x86)JenkinsworkspaceTest_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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...