Jenkins - 环境:“节点”:没有这样的文件或目录

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

我有一个使用配置的詹金斯服务器 https://github.com/shierro/jenkins-docker-examples/tree/master/05-aws-ecs

我是运行一个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"
      }
    }
  }
}

我确保添加 node10 全局工具 w/c 在上面使用

当管道到达脚本 sh "npm install" 时,我 运行 遇到了这个错误

这是命令的输出echo $PATH

所以我认为这不是路径问题

此外,它也无法添加全局包

更多可能有帮助的信息:

知道为什么 jenkins 服务器不知道节点在哪里吗?

非常感谢!

感谢@JoergS 的一些见解!这种情况的罪魁祸首是:使用高山图像作为docker base。所以从 jenkins/jenkins:2.131-alpine 切换到 jenkins/jenkins:2.131 解决了 NodeJS 插件问题。

我遇到了与 jenkinsci/blueocean 相同的问题。我已经通过使用以下命令(在 docker 内)而不是 jenkins 插件

安装 nodejs 来解决这个问题

apk add nodejs

我遇到了与 jenkinsci/blueocean 相同的问题。不需要 jenkins nodejs 插件。

pipeline { 
  agent any 

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

像这样创建一个符号 link:

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

我想强调 Mitch Downey 的评论,它不能只是评论,因为在花了 4 个小时没有找到解决方案后,这条评论帮助我解决了问题

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