I have some troubles setting up the code coverage in SonarQube (Enterprise edition). Previously we have been using the community edition and that has been working fine, but now when are migrating to Enterprise we seem to get some problems with the reports.
- CI system used: Azure DevOps
- Languages of the repository: Java
We have setup a token based service connection and a YAML pipeline where we use Gradle to handle the build.
name: $(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) pool: vmImage: 'Ubuntu 16.04' steps: - task: SonarQubePrepare@4 displayName: 'SonarQube prepare' inputs: SonarQube: 'Sonar Test Enterprise' scannerMode: 'Other' - task: Gradle@2 displayName: 'Build' inputs: workingDirectory: '' gradleWrapperFile: 'gradlew' options: -Pversion=$(Build.BuildNumber) --stacktrace gradleOptions: -Xmx3072m javaHomeOption: 'JDKVersion' jdkVersionOption: '1.8' jdkArchitectureOption: 'x64' publishJUnitResults: true testResultsFiles: '**/TEST-*.xml' testRunTitle: 'Unit Tests' tasks: 'webpackProd build' codeCoverageToolOption: 'jaCoCo' codeCoverageClassFilesDirectories: 'build/classes/java/main/' codeCoverageFailIfEmpty: true checkStyleRunAnalysis: true findBugsRunAnalysis: true pmdRunAnalysis: true sonarQubeRunAnalysis: true sqGradlePluginVersionChoice: 'specify' sonarQubeGradlePluginVersion: '2.6.1' - task: SonarQubePublish@4 displayName: 'SonarQube publish' inputs: pollingTimeoutSec: 300 - task: CopyFiles@2 displayName: 'Copy web.config file to /build/libs' inputs: sourceFolder: '$(build.sourcesDirectory)/azure/app-service/' contents: 'web.config' targetFolder: '$(build.sourcesDirectory)/build/libs/' - task: PublishBuildArtifacts@1 displayName: 'Publish artifact: webapp' inputs: pathtoPublish: '$(build.sourcesDirectory)/build/libs/' artifactName: 'WebApp' inputs: pathtoPublish: '$(build.sourcesDirectory)/build/reports/' artifactName: 'BuildReports' trigger: - master - release/*
This setup has been working fine while using the community edition, but now when we have updated the service connection to point to the new enterprise edition SonarQube we see the code coverage as 0%. We are using the same project key, but have updated the URL and token in the service connection.
We also get this in our logs when building a successful build:
:sonarqube SonarScanner will require Java 11 to run starting in SonarQube 8.x No coverage report can be found with sonar.coverage.jacoco.xmlReportPaths='build/reports/jacoco'. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
When I read the documentation, I understand it as Java 8 should be ok to use for the scanner:
SonarQube scanners require version 8 or 11 of the JVM and the SonarQube server requires version 11. Versions beyond Java 11 are not officially supported.
This is how it looks in SonarQube Enterprise, as you can see we get some data, but are missing the code coverage:
Compared to the same branch in SonarQube Community:
Any idea on what do we need to do to get the code coverage working?