必须学习

导航

解决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

posted on 2019-01-18 16:06  必须学习  阅读(5607)  评论(0编辑  收藏  举报