SonarQube Server Enterprise Edition v2025.1 (ZIP deployment), trying to use sonar.inclusions and sonar.exclusions in an Azure DevOps pipeline. The repo has folders like Folder 1, Folder 2, Folder 3; inside Folder 1 there are Project, Test Project, and Unit Test folders. Set sonar.inclusions to Repo/Folder 1 and sonar.exclusions to "/AssemblyInfo.cs, /.xml,Test.cs,/*.bin", but after analysis the test files and test project still show up in the coverage on the Overview page. Is there a way to use both inclusions and exclusions together without specifying each folder one by one?
Using sonar.inclusions and exclusions together in an ADO pipeline
- sonar.exclusionsproduct
- Azure DevOpsplatform
- SonarQube Server Enterprise Editionproduct
- ADO pipelineplatform
- sonar.inclusionstool
yeah you can use both at the same time, they stack. inclusions decide what gets pulled into the analysis at all, then exclusions trim things out of that set. so you dont need to list every folder one by one.
a couple of things that might be biting you:
- the patterns are relative to the project base dir and theyre case sensitive. if the base dir is already the repo root,
Repo/Folder 1wont match anything. check the analysis logs for the actual base dir and try something likeFolder 1/**instead.
- if the real issue is test files showing up in the coverage on the overview, sonar.exclusions is the wrong knob. that one removes files from analysis completely. to keep test code out of the coverage numbers you want sonar.coverage.exclusions, with patterns matching your test project folders.
also make sure the properties are set in the prepare analysis step of the ADO pipeline, before the build and scanner end step. coverage exclusions are probably your actual fix here.
Source: https://community.sonarsource.com/t/using-sonar-inclusions-and-exclusion/188697