通过jenkins的以下三个方式去执行sonar-scanner,抛如下错误。
Send files or execute commands over SSH before the build starts | |||
Send files or execute commands over SSH after the build runs |
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