Sonar cloud exclusions does not work properly

There are various files which we have excluded from sonar analysis and in the azure devops task we have given them as

sonar.coverage.exclusions = “$(UI_SONAR_Coverage_EXCLUSIONS)”

but there is properties file in sonar which also does the same thing. How to mark files excluded from the sonar analysis. But inspite of certain files in both properties file and that variable(UI_SONAR_Coverage_EXCLUSIONS )above, the files are not getting excluded. Also please let me know the correct way to exclude files from properties file instead of mentioning the values in variable group in azure.

Hi,

At a guess, that variable isn’t interpolated before it’s passed into analysis.

Are you saying sonar.coverage.exclusions is passed in two different places? The settings precedence is described in the docs. To know for sure what values analysis receives, you can add -Dsonar.scanner.dumpToFile=[file path] to your analysis command line.

My preference is to use the UI, but a lot of people want their configurations in “code”. You can pass sonar.coverage.exclusions, as you’ve been doing, in a properties file or on the analysis command line. Just make sure the value you give it is valid and uses the correct wildcard patterns.

 
HTH,
Ann