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

网友投稿 1460 2022-11-30

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

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....." } } }}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:自定义feignClient的常见坑及解决
下一篇:Kubernetes 青云QingCloud 主机上部署 KubeSphere
相关文章

 发表评论

暂时没有评论,来抢沙发吧~