1

I am running Jenkins as a docker container, and have installed the NodeJS plugin and followed thoroughly the setup instructions. When I try to run a script using node, I get the following error:

/tmp/jenkins9123978873441132802.sh: line 1: node: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

I checked the docker volume, the node bin is where it should be and is executable is there and it works fine when I run it from my host server:

user@server:/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin$ ./node --version
v9.2.0

I modified my build script to explore a bit further the problem:

echo $PATH

cd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin
ls -all
./node --version

node --version
npm --version

and look how strange this is:

Building in workspace /var/jenkins_home/workspace/release
[WS-CLEANUP] Deleting project workspace...
[WS-CLEANUP] Done
Adding all registry entries
copy managed file [Main config] to file:/var/jenkins_home/workspace/release@tmp/config69012336710357692tmp
[release] $ /bin/sh -xe /tmp/jenkins6243047436861395796.sh
+ echo /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/jvm/java-1.8-openjdk/jre/bin:/usr/lib/jvm/java-1.8-openjdk/bin
+ cd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin
+ ls -all
total 34112
drwxr-xr-x 2 jenkins jenkins     4096 Nov 20 16:16 .
drwxr-xr-x 6 jenkins jenkins     4096 Nov 20 16:16 ..
-rwxrwxrwx 1 jenkins jenkins 34921762 Nov 14 20:33 node
lrwxrwxrwx 1 jenkins jenkins       38 Nov 20 16:16 npm -> ../lib/node_modules/npm/bin/npm-cli.js
lrwxrwxrwx 1 jenkins jenkins       38 Nov 20 16:16 npx -> ../lib/node_modules/npm/bin/npx-cli.js
+ ./node --version
/tmp/jenkins6243047436861395796.sh: line 1: ./node: not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

The node executable is present, and it's executable (+x). The path is correctly set, but the build still fails.

user5365075
  • 2,094
  • 2
  • 25
  • 42

1 Answers1

0

This is because the path to the node binary

/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin

Does not exist on your shell path.

You should edit Jenkins' variables to adjust your PATH.

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • It does exist in the path. It is automatically set by the NodeJS plugin. I just updated my question with the actual script that is being run. `echo $PATH` shows that the path is indeed correct. When I `cd` into the directory where the `node` executable is, I can see that it is actually there when doing the `ls -all`. So, `./node` should work since I `cd`ed into the correct directory. Still, won't work. – user5365075 Nov 20 '17 at 22:19
  • 1
    If it is on the path, just try using `node` vs `./node`, you right though, this does look strange. – Matt Clark Nov 20 '17 at 22:23
  • Yup, but since `node` points at `/data/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/latest/bin/node`, the behaviour is the same as `cd`ing into that directory and running `./node`. I just did that to make sure the problem wasn't coming from `$PATH`. – user5365075 Nov 20 '17 at 22:25