亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在 Jenkins 管道中使用 Sonarqube 分析 Gradle Java 項目在

在 Jenkins 管道中使用 Sonarqube 分析 Gradle Java 項目在

守候你守候我 2023-03-23 15:25:39
版本: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 FAILEDJaCoCo 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 disabledTask ':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
查看完整描述

1 回答

?
揚帆大魚

TA貢獻1799條經驗 獲得超9個贊

已解決:創建聲納分析所需的臨時文件的用戶授權存在問題,因此您需要使用 Jenkins 的適當用戶運行分析。例如,只需嘗試使用 root 用戶運行它。


此外,SonarQube 需要生成 XML 報告文件,這些文件默認處于關閉狀態。您可以像這樣在 build.gradle 中打開 XML 文件的生成:


jacocoTestReport {

    reports {

        xml.enabled true

    }

}


查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 143 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號