How do you define a specific Pull Request decoration name per project?

Sonar Qube (Development edition) - 9.7.1
Sonnar Scanner - 4.7.0.2747 (.net5 & .net 4.6)

We have two projects in our repo, with different pipelines. These correspond to two different projects in Sonar Qube. Both have their own unit tests and result in a sonar scan with PR decoration to Bitbucket cloud. Problem is the PR can contain changes from both projects so we want to be able to configure a different Pull Request decoration name for each Sonar project (instead of the default “SonarQube”).
If we don’t do that then one build could pass analysis after another fails, resulting in the decoration showing success despite the issues with the first build.

Is there any way to configure this in Sonar Qube, or specify it when calling the scanner?

Please note that the two projects in the repo are part of the same application. We would combine them into a single Sonar Qube scan, but they use different .NET versions (one is .NET 6, the other .NET 4.7.1) and consequently use different versions of the Sonar Scanner.

Hi,

Welcome to the community!

It sounds like you’re looking for monorepo support, which begins in Enterprise Edition($$)

 
HTH,
Ann

Thanks Ann.

Posting here some information sent to me from Sonar, which may aid those viewing this thread in the future:
Dev edition can only decorate a PR once per scan. Alternative solution is to have the Sonar Qube PR decoration in one project, and for the other(s) cause the Team City build to fail by adding in the following parameter to Sonar Scanner in the start command:
/d:sonar.qualitygate.wait=true

This will cause the build to wait for the sonar qube analysis, and if it reports a failure it will fail the build itself - which can trigger Team City decorating the PR with a failed build. The link to the analysis can be found in Team City in the build errors.

An optional additional change would be to implement a specific SonarQube PR decoration sent from Team City. To do this the analysis URL would need to be retrieved as part of the build:

  • Get Analysis ID from the report-task.txt file in the .scannerwork directory after analysis is completed
  • Call /api/qualitygates/project_status?analysisId= and extract the analysis URL from the json returned
1 Like