Excluding java files in sonar report through Jenki

2019-06-19 08:04发布

问题:

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?

回答1:

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.



回答2:

Just pass the "sonar.exclusions" property to your build (for instance using a JVM argument "-Dsonar.exclusions=**/Foo.java").



回答3:

  1. Go to sonar section of your jenkins job.
  2. Click on advanced.
  3. In Additional properties put or add:
    -Dsonar.exclusions=com/company/packageA/generated/**/*.java,com/company/packageB/generated/**/*.java
  4. Save changes.

Notice how multiple packages can be specified using commas.