On this linux server, I have a user named "myuser". For this user, when echoing the path, I get this:
/home/myuser/bin:/home/myuser/.local/bin:/home/myuser/.nvm/versions/node/v6.11.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
Having a node application, when deploying manually I run:
npm i
And it works.
Now, I installed Jenkins. Jenkins project I'm trying to install is located at:
/var/lib/jenkins/workspace/test
The build is executing a shell script. In that window I entered:
#!/bin/bash
npm i
When building with Jenkins, I get this:
[test] $ /bin/bash /tmp/jenkins756533162549346948.sh
/tmp/jenkins756533162549346948.sh: line 3: npm: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
If I only write:
echo $PATH
in the Jenkins shell, I get this:
[test] $ /bin/sh -xe /tmp/jenkins5067097808572366507.sh
+ echo /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/snap/bin
[test] $ /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/6.11.1/bin/node /tmp/jenkins8733250738704177758.js
Finished: SUCCESS
As you can see, I installed nodejs plugin. Anyway, when using Jenkins shell, the npm and even node are not found. How can I make Jenkins to know where npm/node is? I have tried to first write this in the shell:
$PATH=/home/myuser/.nvm/versions/node/v6.11.1/bin
But still no luck.

