【发布时间】:2021-10-29 23:49:02
【问题描述】:
我想从 Jenkins 管道运行 SonarQube Scanner,我按照文档进行操作。
关于错误,似乎存在扫描仪但未找到某些命令。我的 jenkins 实例在本地运行。
错误信息:
+ /usr/local/bin/sonar-scanner
/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/libexec/bin/sonar-scanner: line 17: dirname: command not found
/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/libexec/bin/sonar-scanner: line 18: basename: command not found
/usr/local/Cellar/sonar-scanner/4.6.2.2472_1/libexec/bin/sonar-scanner: line 28: dirname: command not found
File does not exist: //lib/sonar-scanner-cli-4.6.2.2472.jar
'/' does not point to a valid installation directory: /
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
脚本管道:
node {
stage('Preparation') {
try{
// Clone Project from bitbucket
git url: 'https://test@bitbucket.org/test/test.git'
}catch(err){
echo err
}
}
stage('Sonarqube') {
sh '/usr/local/bin/sonar-scanner'
}
stage('end') {
echo "Success"
}
}
【问题讨论】:
-
您的问题是
sonar-scanner而取决于在环境中找到正常的unix 命令。dirname和basename应该在/usr/bin中。结果是它无法正确build the path 到二进制文件。检查echo $PATH并修复。比安装 docker 更容易解决;但没有足够的信息。你是怎么安装cli的? -
另外,@VonC 的 answer to a different problem 和旧版本可以解决您的问题。
标签: jenkins sonarqube jenkins-pipeline sonarscanner