We have a Java project with 2 separate builds in Jenkins.
One of the builds runs integration tests, and generates code coverate (JaCoCo), which we feed into sonarscanner. When this build runs and succeeds, we see code coverage in SonarCloud showing up. This build is executed via the following:
mvn sonar:sonar -Dsonar.branch.name='$BRANCH' -Dsonar.coverage.jacoco.xmlReportPaths=target/jacoco-tests/jacoco.xml --batch-mode
The second build only runs the sonar analysis (without the integration tests), and thus no code coverage data is available. We completely omit the coverage related parameters from sonarscanner. When this build runs, the code coverage in SonarCloud gets reset to 0%.
This build is executed via the following:
sonar-scanner -Dproject.settings=./sonar-project.properties -Dsonar.branch.name="$BRANCH"
Is this expected behavior?
Any help / guidance would be greatly appreciated.