Thursday, 16 March 2017

npm/nodejs on Jenkins

I am trying to make npm/nodejs work on Jenkins (v2.32.3) but having issues after upgrading the Nodejs plugin from version 0.2.2 to 1.1.2.

I have manually downloaded Nodejs and extracted it in /etc/nodejs/node-v6.9.4-linux-x64, and I have configured it in Global Tool Configuration.

I have a simple job configured like this (Execute shell):

echo $PATH
whoami
npm --version
node --version

The result is:

[EnvInject] - Loading node environment variables.
Building in workspace /var/lib/jenkins/jobs/test- nodejs_test/workspace
[workspace] $ /bin/sh -xe /tmp/hudson1755936462393481437.sh
+ echo /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
+ whoami
jenkins
+ npm --version
/tmp/hudson1755936462393481437.sh: 4: /tmp/hudson1755936462393481437.sh: npm: not found
Build step 'Execute shell' marked build as failure
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: FAILURE

I have no idea why it is failing, I believe it is because the PATH is not set. However if I log into the Jenkins server and have the PATH specified in /etc/environment it works in the shell but not in Jenkins as:

jenkins@JENIS-SERVER:/home/user$ npm --version
3.10.10



via user3270211

No comments:

Post a Comment