10

I have a jenkins server that is configured using https://github.com/shierro/jenkins-docker-examples/tree/master/05-aws-ecs

I am running a blue ocean pipeline using a simple Jenkinsfile and the jenkins NodeJS plugin

pipeline { 
  agent any 

  tools {
    nodejs 'node10'
  }

  stages {
    stage ('Checkout Code') {
      steps {
        checkout scm
      }
    }
    stage ('Install dependencies') {
      steps {
        sh "echo $PATH"
        sh "npm install"
      }
    }
  }
}

I made sure to add the node10 global tool as well w/c is used above enter image description here

When the pipeline gets to the script sh "npm install" i am running through this error enter image description here

this is the output of the command echo $PATH enter image description here

so i think it's not a path issue

Also, it also wasn't able to add the global package enter image description here

More info that might help:

  • Docker Jenkins server: FROM jenkins/jenkins:2.131-alpine
  • Blue ocean version: 1.7.0
  • NodeJS Plugin: 1.2.6
  • Multiple server restarts already

Any ideas why the jenkins server does not know where node is?

Big thanks in advance!

Theo
  • 1,932
  • 4
  • 17
  • 40
  • Is the node binary in your path? – iJos Jul 19 '18 at 09:39
  • @iJos yes it is. i accessed the docker image and i see `npm` & `node` on /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin – Theo Jul 19 '18 at 09:42
  • 3
    I tried a slightly reduced code snippet on my local Jenkins (w/o docker) - and it worked. Maybe something's wrong with the docker setup? In the build log, did you see that node actually was downloaded and unzipped into that very folder where the path points to? – Joerg S Jul 22 '18 at 07:55
  • 1
    @JoergS thanks for the insight - that's a possibility, maybe the alpine version is not compatible with the plugin? There's no build log shown to download on the pipeline step, but i see that the node executable is already downloaded on path `/var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node10/bin`. i'll try the image jenkins/jenkins:lts & get back – Theo Jul 24 '18 at 07:03
  • Hey @JoergS you can post an answer so I can give you some credit :) – Theo Aug 01 '18 at 23:08
  • @Theo: Thanks for the suggestion. However I feel like it was more like a combined effort :) You may upvote my comment if you like. Think that’s enough credit for me on that one. – Joerg S Aug 02 '18 at 06:16
  • @JoergS as you say mate :) Thanks again! really appreciate your help – Theo Aug 02 '18 at 10:53
  • 1
    Thanks for posting the very detailed questions. I was able to fix my issue just by seeing a good configured environment and description. – JeanCarlos Chavarria Jan 17 '20 at 22:48

5 Answers5

9

Thanks to @JoergS for some insight! The culprit in this case is: using alpine image as the docker base. So switching from jenkins/jenkins:2.131-alpine to jenkins/jenkins:2.131 solved the NodeJS plugin issue.

Theo
  • 1,932
  • 4
  • 17
  • 40
  • 2
    My issue ended up being with the jenkinsci/blueocean image. I was able to just replace that image with jenkins/jenkins:lts and the NodeJS plugin began working as expected. – Mitch Downey May 03 '20 at 19:03
2

I have faced the same issue with jenkinsci/blueocean. I have resolved this by installing nodejs with below command(inside docker) not as jenkins plugin

apk add nodejs

Jay Reddy
  • 630
  • 7
  • 6
  • I am also running jenkinsci/blueocean and facing the same issue. Can you please provide me the solution in detail? It would be very helpful. – mrSaraf Aug 01 '19 at 06:20
1

I have faced the same issue with jenkinsci/blueocean. No jenkins nodejs plugin needed.

pipeline { 
  agent any 

  stages {
    stage ('Checkout Code') {
      steps {
        checkout scm
      }
    }
    stage ('Install dependencies') {
      steps {
        sh "apk add nodejs"
        sh "echo $PATH"
        sh "npm install"
      }
    }
  }
}
0

Make a symbolic link like this:

sudo ln -s /var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node/bin/node /usr/bin/node

0

I want to highlight Mitch Downey's comment, it can't be just a comment because after spending 4 hours with no solution this comment helped me to resolve the solution

My issue ended up being with the jenkinsci/blueocean image. I was able to just replace that image with jenkins/jenkins:lts and the NodeJS plugin began working as expected

madhu131313
  • 7,003
  • 7
  • 40
  • 53