Ivan Vlaho Vlašić
Ivan Vlaho Vlašić

Reputation: 13

Jenkinsfile npm build failed

I installed Jenkins from the latest docker image, configured everything, installed NodeJS plugin, created a new pipeline job from Git SCM and created a simple Jenkinsfile to run a new job.

pipeline {
  agent any

  tools {
    nodejs 'node'
  }

  stages {
    stage('Clone') {
      steps {
        git branch: 'develop',
            credentialsId: 'gitea-jenkins',
            url: 'http://x.x.x.x:3000/TestRepo'
      }
    }

    stage('Install') {
      steps {
        dir('frontend') {
          sh 'npm config ls'
        }
      }
    }
  }
}

The Clone stage is ok but the Install stage fails without explanation. It's a problem with nodejs and the tools declaration as if the node's plugin is not visible at all.

Here is the output:

Running in /var/jenkins_home/workspace/Project/frontend
[Pipeline] {
[Pipeline] nodejs
[Pipeline] {
[Pipeline] sh
+ npm config ls

[Pipeline] }
[Pipeline] // nodejs
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Build)
Stage "Build" skipped due to earlier failure(s)
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 243
Finished: FAILURE

Please help!

Upvotes: 1

Views: 1553

Answers (1)

andrewgi
andrewgi

Reputation: 632

This is a user permissions error as described here https://github.com/nodejs/docker-node/issues/1734

The solution is to either use yarn, downgrade node back to 16.14 for the time being, or change to the node user.

Upvotes: 1

Related Questions