問題描述:
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