I am running sonar from Jenkins. I want to exclude some java files in the sonar report. Is that possible through Jenkins? If yes, how can I do that?
You can prevent some files from being taken into account for code coverage by unit tests. To do so, go to Project Settings > General Settings > Analysis Scope > Code Coverage and set the Coverage Exclusions property. See the Patterns section for more details on the syntax.
sonar.exclusions will exclude mentioned files or directories from analysis. sonar.coverage.exclusions still exists and will exclude mentioned files or directories from code coverage like in question asked. But it's not mentioned in current documentation.
coverage. exclusions excludes some files from the test coverage metrics but those files are still analyzed: other metrics, duplications, coding rules... sonar. exclusions completely excludes some files from the analysis: those files don't appear at all in SonarQube.
Assuming you are using jenkins sonar plugin, refer to this documentation on how to configure the plugin to specify additional parameters which allow files to be excluded from analysis.
Just pass the "sonar.exclusions" property to your build (for instance using a JVM argument "-Dsonar.exclusions=**/Foo.java").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With