Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 991
user1354743 Avatar asked Apr 12 '13 12:04

user1354743


1 Answers

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
like image 100
Ewan Avatar answered Oct 14 '22 21:10

Ewan