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


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

Help for feature: Send files or execute commands over SSH before the build starts
     

 

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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM