Jenkins管道中出现错误“ / usr / bin / env:'节点':没有这样的文件或目录”

时间:2018-07-16 11:52:03

标签: node.js jenkins jenkins-plugins jenkins-pipeline

我在Jenkins中创建了一个管道,对Node.js应用程序进行了以下配置:

pipeline {
agent any
stages {
    stage('Build') {
        steps {
            nodejs(nodeJSInstallationName: 'Node8') {
                sh 'npm install'
            }
        }
    }
    stage('Test') {
        steps {
            nodejs(nodeJSInstallationName: 'Node8') {
                sh 'npm run test'
            }
        }
    }
    stage('Deploy') {
        steps {
            nodejs(nodeJSInstallationName: 'Node8') {
                sh 'npm run start'
            }
        }
    }
}

}

但是'npm'的执行失败,这给了我以下错误:

+ npm install
/usr/bin/env:'node': No such file or directory

我使用Docker在我的服务器上安装了Jenkins(图像jenkins / jenkins:lts),并在Jenkins中安装了NodeJS插件。

我以这种方式创建了Node工具:

enter image description here

你知道会发生什么吗?

问候。

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

试试这个

sudo ln -sf "$(哪个节点)" /usr/bin/node