which versions are you using (SonarQube Server / Community Build, Scanner, Plugin, and any relevant extension) :- Enterprise Edition v2025.1 (102418)
how is SonarQube deployed: zip, Docker, Helm:- ZIP
what are you trying to achieve:- Using onar.Inclusions and Exlcusions in ADO Pipeline
what have you tried so far to achieve this:- Added path of folder to be included and excluded
Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!
We have a repo in which we have many folders like Repo => Folder 1 and Folder 2 and folder 3…
With in Folder 1 we Project Folder and Test Project Folder and Unit Test folder. I have included Sonar.Inclusions = Repo/Folder 1 and Sonar Exclusions = “**/AssemblyInfo.cs, */*.xml,Test.cs,/*.bin”
But When we run the analysis it still shows the Test files and test project should be covered. in Overview.
is there any way we can use both Inclusions and exclusions rather than specifying each folder one by one.
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 1 wont match anything. check the analysis logs for the actual base dir and try something like Folder 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.
Hey @sunil.bindra, assuming your test code is correctly detected as test code (and not as main code), then sonar.exclusions/sonar.inclusions won’t work on them. The correct properties would be sonar.test.exclusions/sonar.test.inclusions (or the equivalent UI fields in the project settings). Please see Excluding based on path-matching patterns | SonarQube Cloud | Sonar Documentation .
the short version: inclusions decide what enters analysis at all, exclusions trim main code, sonar.test.exclusions and sonar.test.inclusions handle test code, and sonar.coverage.exclusions handles the coverage numbers. they stack, so you dont list folders one by one. all patterns are relative to the project base dir and case sensitive, and in an ADO pipeline they need to be set in the prepare step before build.
I’ve resolved the issue by using Sonar.Sources to define the coverage scope and Sonar.Exclusions to filter out unnecessary code. The coverage is now accurate and excludes what we don’t need.