我在Jenkinsfile中遇到Jenkins管道的问题。我的Jenkins实例上有4个不同的nodeJs版本。我想选择要在管道中使用的那个,但是官方插件示例(https://wiki.jenkins-
ci.org/display/JENKINS/NodeJS+Plugin)根本不起作用。
我尝试了第一种方法,但由于$ PATH被该tools部分覆盖而失败。
pipeline {
agent any
tools {
// I hoped it would work with this command...
nodejs 'nodejs6'
}
stages {
stage('Example') {
steps {
sh 'npm --version'
// Failed saying :
// Running shell script
//nohup: failed to run command 'sh': No such file or directory
}
}
}
}
我尝试了第二种方法,但失败了,因为该tool命令似乎根本不起作用。
pipeline {
agent any
stages {
stage('Example') {
steps {
// ... or this one
tool name: 'nodejs6