Jenkins 2.50 中声明性管道中的以下 SonarQube (6.3) 分析阶段失败,并在控制台日志中显示此错误:http://pastebin.com/t2ja23vC http://pastebin.com/t2ja23vC。进一步来说:
此作业 (SonarGate) 中定义的 SonarQube 安装与任何配置的安装都不匹配。可配置的安装数量:1。
Update:在 Jenkins 设置中将“SonarQube”更改为“SonarGate”(在 SonarQube 服务器下,因此它将与 Jenkinsfile 匹配)后,我收到不同的错误:http://pastebin.com/HZZ6fY6V http://pastebin.com/HZZ6fY6V
java.lang.IllegalStateException:无法获取 SonarQube 任务 ID 和/或服务器名称。请使用“withSonarQubeEnv”包装器来运行您的分析。
该阶段是 SonarQube 文档中示例的修改:https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Jenkins#AnalyzingwithSonarQubeScannerforJenkins-AnalyzinginaJenkinspipeline
stage ("SonarQube analysis") {
steps {
script {
STAGE_NAME = "SonarQube analysis"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, don't analyze."
}
else { // this is a PR build, run sonar analysis
withSonarQubeEnv("SonarGate") {
sh "../../../sonar-scanner-2.9.0.670/bin/sonar-scanner"
}
}
}
}
}
stage ("SonarQube Gatekeeper") {
steps {
script {
STAGE_NAME = "SonarQube Gatekeeper"
if (BRANCH_NAME == "develop") {
echo "In 'develop' branch, skip."
}
else { // this is a PR build, fail on threshold spill
def qualitygate = waitForQualityGate()
if (qualitygate.status != "OK") {
error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
}
}
}
}
}
我还创建了一个网络钩子,sonarqube-webhook
,与网址http://****/sonarqube-webhook/
。是不是应该这样,或者http://****/sonarqube/sonarqube-webhook
?要访问我使用的服务器仪表板http://****/sonarqube
.
在 SonarQube 质量门部分中,我创建了一个新的质量门:
我不确定 SonarGate 中的设置是否正确。我确实使用 jenkins-mocha 生成 lcov.info 文件,该文件在 Sonar 中用于生成覆盖数据。
也许质量门设置是错误的设置?如果未达到覆盖率,最终结果是 Jenkins 的工作失败。
最后,我不确定Jenkins系统配置中是否需要以下配置:
And
(It's 9000 not 900... cut text in the screen shot)