SonarCloud analysis in an Azure Pipelines multi-stage build

Is there a way to run SonarCloud analysis on an already built project? Our build process is split into multiple stages so that testing (unit, integration, security, etc.) can be run as parallel stages to reduce build time. I can’t get SonarCloud to work if I’m downloading the build artifacts after the fact, even if I run all the prep steps. It also can’t report unit test coverage since I’m running that in a separate stage from the build as well.

Any suggestions?

Hi @thisjustin816 and welcome to the community !

What the is language of your project ? For most of the case, we strongly encourage to run the analysis during the build itself, you will then ensure that no artifact will be published if a Quality Gate has not passed, or if the execution of the analysis has failed.

Technically speaking, SonarCloud will need all the reports (for coverage for example) to be put in a specific directory that you provide using relevant properties (sonar.*.coverage.reportPaths usually), and it will also need to find source files at the place where they have been declared.


Hi Mickael,

It’s .net and typescript. It is run during the same build. I’m just splitting it into stages.

Is there somewhere where it’s documented exactly what SonarCloud needs to find the files?

@mickaelcaro any thoughts?

Hi @thisjustin816

We don’t have any documentation on that specific use case.

For sure for the .NET Build you will need to run the analysis in the same stage as the build itself, because we are hooking up in the MSBuild task, so this is a requirement.

For you typescripts files, are you using a separate build ? If yes, then it will not be compatible with using the same SonarCloud project, this is not yet supporter on our side.

So for that you can trigger multiple SonarCloud analyses on your different stages, but they will have to have their dedicated SonarCloud project.