jenkins执行shell提示命令不存在
问题描述:
jenkins编译项目,不继承linux环境变量 ~/.bash_profile ~/.bashrc /etc/profile,导致在执行shell脚本,提示命令找不到!
[sz-hgzx-web] $ /bin/sh -xe /home/jenkins/jenkins-tomcat/temp/jenkins3481283604636839646.sh + cd hgzx-web-deploy/hgzx-front + npm run build sz /home/jenkins/jenkins-tomcat/temp/jenkins3481283604636839646.sh: line 3: npm: command not found //npm命令找不到 Build step '执行 shell' marked build as failure Finished: FAILURE
问题解决:
00、之前脚本前执行环境变量的刷新
source /etc/profile
source ~/.bash_profile
11、建立标准软连接
ln -sv xxx/bin/node /usr/local/bin/node
ln -sv xxx/bin/npm /usr/local/bin/npm