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