Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run npm/grunt command from jenkins

I'm new to this area and was trying to run the following commands from jenkins:

npm install
grunt quickStart

So far I've a jenkins running on a window machine as a window service and I've also installed NodeJs plugin for jenkins.

However, I'm stuck and quit confused following instructions here, its asking me to to add one or mode nodeJs installation and I could not find those setting and not even sure if I even need them in the first place.

Here is the bit that's asking me to do: enter image description here

I cannot see this setting for the jenkins job I create. Is there an easy way to run those command in jenkins from a .bat or .sh script, a .bat would be recomended since I'm on window machine.

Note : I've already checked out a project using git in jenkins!!!

Thanks

like image 733
Simple-Solution Avatar asked Sep 18 '14 17:09

Simple-Solution


People also ask

How run Jenkins npm install?

The way I made it, was trough execute shell, as the build tool for nodejs is npm, I simply wrote a shell script that instructs jenkins to run npm install in the workspace directory inside jenkins where it clones the git repository and then to zip and move the package if successful to another folder.

How do I run local grunt?

Installing grunt-cli locally If you prefer the idiomatic Node. js method to get started with a project ( npm install && npm test ) then install grunt-cli locally with npm install grunt-cli --save-dev. Then add a script to your package. json to run the associated grunt command: "scripts": { "test": "grunt test" } .


2 Answers

"its asking me to to add one or mode nodeJs installation and I could not find those setting and not even sure if I even need them in the first place."
I don't think you need that I have pointed jenkins to the node installation folder an nothing more.., for this you go to Manage Jenkins->Configure System->NodeJS->NodeJS installations.. type in any name you like and point to where the node home folder is.

node home directory...cannot see this setting for the jenkins job I create...

Once you have configure that in your jenkins configuration you should have that configuration available like so:

node in project

...Is there an easy way to run those command in jenkins from a .bat or .sh script, a .bat would be recomended since I'm on window machine
I'm sorry don't get what commands are you referring to... so summarizing :

  1. you have to tell jenkins where you have your node installation
  2. use that configuration in your jobs

hope this helps...

like image 86
yokodev Avatar answered Sep 20 '22 21:09

yokodev


The way I made it, was trough execute shell, as the build tool for nodejs is npm, I simply wrote a shell script that instructs jenkins to run npm install in the workspace directory inside jenkins where it clones the git repository and then to zip and move the package if successful to another folder.

like image 26
PyTux Avatar answered Sep 22 '22 21:09

PyTux