Jenkins integration with Grunt

二次信任 提交于 2019-11-28 09:03:19
aqm

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

You will need to restart the Jenkins service after installing node, presumably to cause it to refresh its cached copy of your PATH environment variable

I have grunt doing some tasks for me in Jenkins, but I went the npm script route. Grunt and grunt-cli are dev dependencies, and I have the following defined in my package.json file:

"scripts": {
    "test": "node node_modules/grunt-cli/bin/grunt test"
},

In Jenkins (running on Windows), I added two post-build tasks:

npm install

npm test

We just installed NodeJs normally on the Jenkins server.

Another solution that worked for me on Windows is to use the full path to the grunt exec file, which can be found by writing "where grunt" in the command shell. I used the full path in the regular bat-file.

Had the same issue on Windows. When I manually installed node and ran npm install -g grunt-cli from command line, jenkins could not recognize the grunt command. So uninstall node, reinstall it but dont run npm install. Then restart the jenkins slave. Then from the jenkins job that runs on your specific jenkins slave, make it run a Windows batch command that runs npm install -g grunt-cli After that again restart the jenkins service. Then from the job run npm install. Then everything worked for me. If issues still persist, then uninstall the slave, and reinstall it, then everything works fine immediately.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!