Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jenkins - env: ‘node’: No such file or directory

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!

like image 941
Theo Avatar asked Jul 19 '18 07:07

Theo


People also ask

Is there a file or directory error in Jenkins?

Jenkins No such file or directory error. But the file exists Ask Question Asked8 years, 7 months ago Active3 years ago Viewed26k times 9 3 I have a problem with running bash script as a job in Jenkins (Execute shell step).

How to view environment variables in Jenkins using shell command?

For instance, when logging in on your system using the default port 8080: Another method is to create a Jenkins job that executes a shell command to view environment variables. The console output of this job is a modified version of the environment variables list.

How do I install envinject in Jenkins?

Click Manage Jenkins on the left-hand side of the dashboard. 2. In the System Configuration section, click the Manage Plugins button. 3. Under the Available tab, search for envinject.

When is a Jenkins build not marked as failed?

0 Jenkins build is not marked as failed if there is an error during .sh file execution 0 How do I make jenkins to execute particular file 0 No such file or directory error in Jenkins shell script that works well in another jobs


3 Answers

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.

like image 186
Theo Avatar answered Oct 12 '22 16:10

Theo


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

like image 28
Jay Reddy Avatar answered Oct 12 '22 16:10

Jay Reddy


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"
      }
    }
  }
}
like image 41
Devops Anil Avatar answered Oct 12 '22 16:10

Devops Anil