0
点赞
收藏
分享

微信扫一扫

jenkins中/usr/bin/env: node: No such file or directory


两种方式解决:

第一种:创建node软连接到/usr/sbin目录下

ln -s /application/node-v14.2.0-linux-x64/bin/node /usr/sbin/node

第二种:

在执行sh时添加环境变量

pipeline{
agent {
node { label "master" }
}
parameters{
choice(choices: ["-v","build"],description: "npm",name: "buildShell")
}
stages{
stage("npm构建"){
steps{
script{
nodejs_home = tool "NPM"
sh "export PATH=\$PATH:${nodejs_home}/bin && ${nodejs_home}/bin/npm ${buildShell}"
}
}
}
}
}

def buildTools = ["web": "/usr/local/node-v14.16.1-linux-x64"]

pipeline {
agent { label "build" }
options {
skipDefaultCheckout true
}

stages {
stage("GetCode"){
steps{
script{
checkout([$class: 'GitSCM',
branches: [[name: "${branchName}"]],
extensions: [], userRemoteConfigs:
[[credentialsId: "${credentialsId}",
url: "${srcUrl}"]]])
}
}

}

stage("Build"){
steps {
script {
sh """
export PATH=\$PATH:${buildTools["web"]}/bin
${buildTools["web"]}/bin/npm install
${buildTools["web"]}/bin/npm run build
"""
}
}
}

}

post {
always {
script{
echo "always......"

}
}

success {
script {
echo "success....."
}
}
}

}

 

举报

相关推荐

0 条评论