user1354743
user1354743

Reputation: 417

run Grunt.js with Jenkins

I've set up a Gruntfile with mocha testing and JSlint. This works fine if i just run grunt form the terminal.

I want to run grunt from Jenkins!

I set up a new job -> and made built to a shell script and included:

/usr/local/bin/grunt

Once I run the job the terminal output of Jenkins says:

[workspace] $ /bin/sh -xe /tmp/hudson8550584576040162032.sh
+ /usr/local/bin/grunt
/usr/bin/env: node: No such file or directory
Build step 'Execute shell' marked build as failure
Finished: FAILURE

it seems it cant fine node binary!?! but node is installed and runs fine in the terminal!

All my binaries (mocha, grunt, node) are in /usr/local/bin/

Does anyone know what the issue is? Or maybe someone has a link to set up grunt.js with jenkins?

Somebody got something?

Thx

Upvotes: 16

Views: 11825

Answers (3)

aqm
aqm

Reputation: 3034

you can allow setup everything from jenkins :

Install Jenkins Plugins

  • Git Plugin - for git
  • Git Client Plugin - for git
  • Git Parameter Plugin - for git tags
  • GitHub API Plugin - for github
  • NodeJS Plugin - integration for common javascript tools NodeJS & npm

Git / Ant / Maven / NodeJS Installations

  • Goto SERVER/jenkins/configure
Git
  • Git -> Git installations -> Add Git -> JGit
  • Git plugin -> Global Config user.name Value = "Anthony Mckale", Global Config user.email Value = "[email protected]"
NodeJS
  • 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

TADA

and hopefully git/nodejs and grunt will be available to you

Upvotes: 0

Ewan
Ewan

Reputation: 15078

This is happening because Jenkins will be running as a different user which probably doesn't have /usr/local/bin in its $PATH.

In your shell script make sure /usr/local/bin is being added to your $PATH

export PATH="/usr/local/bin:$PATH"
# This will also mean you can call 'grunt' rather than '/usr/local/bin/grunt'
grunt

This has the added benefit of calling any programs you've installed in /usr/local/bin over anything in /usr/bin. If you don't want this behavior, simply append instead of prepend:

export PATH="$PATH:/usr/local/bin"
# This will also mean you can call 'grunt' rather than '/usr/local/bin/grunt'
grunt

Upvotes: 19

Qorbani
Qorbani

Reputation: 5905

To be honest I'm not familiar with Jenkins but I had same issue when I wanted to integrate GruntJS with XCode custom build step or within TeamCity deployment process.

I fixed my problem by adding /usr/local/bin/ to the PATH within my shell script before running grunt or node. Something like:

PATH=${PATH}:/usr/local/bin
grunt

I hope this helps you as well :-)

Upvotes: 1

Related Questions