Sonarcloud exclusion path issue

We have an issue when we tried moving two of our repositories from SonarQube to SonarCloud. Setting the exclusions as they were in SonarQube does not seem to work.
We set some files to be excluded via “sonar.exclusions” and “sonar.test.exclusions”. These files are not ignored as expected and cause the quality gate to fail as sonar scans the files and comments on them. These files are config files for unit tests.
The strings we tried using to ignore these files include:

The whole test folder: **/*.Tests/**

The complete path to the file: Tests/PersonService.Component.Integration.Tests/Configuration/fat-sbx_config.json

The relative path to the file: **/fat-sbx_config.json

How we send in these strings is by repository specific yml file that defines these strings, then sends it into our centralized pipelines as string and is there referenced as parameters (sonar.exclusions=${{ parameters.sonarExclusions }}), like we do all the settings there even though some are variables.
After extensive testing of different strings through the yml and setting the strings directly in the SonarCloud UI one solution worked. That is defining the string directly, without quotes, in the SonarCloudPrepare step. This is not the solution we were searching for as this means we will need to have the same exclusion for every single repository we have, and the number of repositories is extensive. The worst part is that they are all very different and so finding one exclusion step for all will be quite tricky.

We had some thought as to what was causing this:

The SonarCloudPrepare task cannot handle the parameter value correctly, this is a yml string and perhaps it does not process it correctly

The repository has multiple projects and the whole repository is scanned by one SonarCloud project and setting is not set to monorepo, this is perhaps not the way it was designed and therefore fails on the scan somehow


Welcome to the community!

I’m not sure we do variable interpolation in any of the scanners. The assumption is that the values you pass in are ready for use.

I’m quite surprised that setting the values directly in the UI didn’t work. Or did you try setting variables in the UI with the expectation they would be interpolated at run time? Because “defending the string directly, without quotes” in the UI will work.

BTW, I would not expect this to work:

** means 0-n directories. You would need to use this instead: