解决jenkins shell执行sonar-scanner提示命令存在的问题

通过jenkins的以下三个方式去执行sonar-scanner,抛如下错误。

Send files or execute commands over SSH before the build starts 解决jenkins shell执行sonar-scanner提示命令存在的问题
     
Send files or execute commands over SSH after the build runs

解决jenkins shell执行sonar-scanner提示命令存在的问题

command [cd /home/xxx/code/CODE/xxx/xxx
sonar-scanner...
bash: sonar-scanner: command not found
SSH: EXEC: completed after 200 ms
SSH: Disconnecting configuration [zftest] ...
ERROR: Exception when publishing, exception message [Exec exit status not zero. Status [127]]
Build step 'Send files or execute commands over SSH' changed build result to UNSTABLE
Finished: UNSTABLE

原因是:jenkins编译项目,不继承linux环境变量 ~/.bash_profile  ~/.bashrc  /etc/profile,导致在执行shell脚本,提示命令找不到!

解决方法:在服务器执行ln -sv /usr/local/sonar-scanner/bin/sonar-scanner /usr/local/bin/sonar-scanner

上一篇:山特UPS电源后备式MT500


下一篇:python os用法详解