Sonar.exclusions not working properly with SonarQubePrepare task in our Azure Pipeline script

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) → SonarQube version 10.6.0.92116 with SonarQubePrepare@6 task template
  • how is SonarQube deployed: zip, Docker, Helm → Docker
  • what are you trying to achieve → our pipline task for the preparation of SonarQube quality check analysis are configured as follows:
  task: SonarQubePrepare@6
            inputs:
              SonarQube: 'SonarQube'
              scannerMode: 'MSBuild'
              projectKey: 'OurKey'
              extraProperties: |
                sonar.coverageReportPaths="$(SonarQubeCoverageFile)"
                sonar.cs.vstest.reportsPath="$(Agent.TempDirectory)/**/*.trx"
                sonar.exclusions="$(SonarQubeExclusions)"

where the variable “SonarQubeExclusions” is defined as follows:

SonarQubeExclusions: OurProjectLocation/SubFolder1/**/*, OurProjectLocation/SubFolder2/**/*, OurProjectLocation/SubFolder3/**/*

While running the Analyze task SonarQube reports that it will exclude the folders like defined, but when checking the resulting analysis reports it wasn’t excluded properly.

  • what have you tried so far to achieve this → I’ve added the exact same exclusion pattern to Analysis Scope → Source File Exclusions settings within the General Project Settings provided by the web interface of SonarQube and it worked as intended.

Hey there.

Since these exclusions get evaluated at the module level, I suggest you add a folder wildcard before each (so OurProjectLocation/SubFolder1/**/* becomes **/OurProjectLocation/SubFolder1/**/*)

Hi,

thanks for the quick support. Seems to working now!

Best regards,
Florian

1 Like