How to work on this "Dsonar.coverage.exclusions" flag to exclude some file

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve:

sonar-scanner -Dsonar.coverage.exclusions=‘xyz/*’`

  • what have you tried so far to achieve this: “-Dsonar.coverage.exclusions” flag is not working

Can someone explain me how we can use this -"
Dsonar.coverage.exclusions" to exclude some file.


sonar.coverage.exclusions doesn’t exclude files from analysis. It excludes them from coverage calculations. I recommend you set exclusions via the UI. One benefit of that is that there are section headings and brief description of each property there.

You’re looking for sonar.exclusions, under the Files section.


I tried to use Dsonar.exclusions It also didn’t work. Can you briefly explain what you try to mean.

Because I am trying to do it on gitlab ci yaml so I am not able to set it on UI side I need a flag like ‘Dsonar.exclusions`Something like that so that when I use sonar scanner command like it exclude the file


I truly don’t understand why that would be a limitation or have an impact.

Nonetheless, you set the flag on the analysis side with -D[parameterKey]=[parameterValue]. It looks like you’ve been leaving off the initial -.