版本:SonarQube:7.9 SonarJava 插件:5.13.1 Java:11 Gradle:5.5
我正在尝试使用声明性 Jenkins 管道对 Gitlab Repo 和 Gradle/Java 项目进行 SonarQube 分析。这是詹金斯文件:
@Library('jenkins-shared')_
pipeline {
agent {
docker {
image 'gradle:5.5-jdk11'
}
}
stages {
stage('build && SonarQube analysis') {
steps {
withSonarQubeEnv('sonar.tools.****) {
script {
cmd.withNexusCredentials {
sh 'gradle --info sonarqube -Dsonar.projectKey=catalog-service -Dsonar.junit.reportPaths=./build/test-results/test -Dsonar.binaries=./build/classes -Dsonar.coverage.jacoco.xmlReportPaths=./build/reports/jacoco/test/html/index.html'
}
}
}
}
}
stage("Quality Gate") {
steps {
timeout(time: 1, unit: 'HOURS') {
// Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// true = set pipeline to UNSTABLE, false = don't
// Requires SonarScanner for Jenkins 2.7+
waitForQualityGate abortPipeline: true
}
}
}
}
}
我也将 Sonar 插件应用于 Gradle 构建文件。当我尝试运行此 Jenkins 管道时,出现以下错误:
> Task :sonarqube FAILED
JaCoCo report task detected, but XML report is not enabled or it was not produced. Coverage for this task will not be reported.
Caching disabled for task ':sonarqube' because:
Build cache is disabled
Task ':sonarqube' is not up-to-date because:
Task has not declared any outputs despite executing actions.
JaCoCo report task detected, but XML report is not enabled or it was not produced. Coverage for this task will not be reported.
User cache: ?/.sonar/cache
:sonarqube (Thread[Execution worker for ':',5,main]) completed. Took 0.221 secs.
其他所有任务都成功完成。即使当我运行 jacocoTestConverageVerification 或检查时,它总是成功运行,除了任务 Sonarqube
扬帆大鱼
相关分类