Search code examples
reactjsazure-devopssonarqubeazure-pipelinessonarcloud

Steps required to do multiple scans in a single pipeline


Can anyone help me to understand what's necessary to perform several sonar scans in a single pipeline? I've read that sonarcloud doesn't support multiple project scans into a single project, so i separated them into different sonarcloud projects.

I am using the SonarCloud scanner extension from the marketplace, on hosted build agents.

I have a rather large .net ASP.NET MVC legacy framework application, which also includes a reactjs application in the Scripts folder. I don't want to include the reactjs files in the msbuild scan because this is constantly changing, and the developer uses vscode rather than visual studio. Keeping the csproj up to date would be a nightmare.

So I want to scan the reactjs folder separately using the stand-alone scanner, and use the msbuild scanner with the .net app.

The scanner works fine for the .net app, but i'm unable to get any scan output from the stand-alone scanner. It just shows an empty result.

I've got the following tasks...

Prepare Analysis (separate sonarcloud project) npm install npm build Run Analysis

Prepare Analysis (for .net) (separate sonarcloud project) nuget restore visual studio build task Run Analysis

Publish build gate Upload artifacts

I've set the sonar.exclusions of the .net project (on the sonarcloud admin settings, not in a file in my scm) to exclude the reactjs folder (Scripts/react/**/*), and scanning of the .net project seems to work.

I've set the sonar.sources for the javascript scanner task to be the reactjs folder

However, the javascript scan is empty.

I'm at a loss...

Is it the fact that i'm running two scans in the same pipeline? Do i need to run the build gate after the JS scan as well? Is the second scan overwriting the first? Does the Run Analysis actually publish the results or is the Publish build gate?


Solution

  • So the problem was that i was using an includes parameter in my stand-alone scanner to scan only the subfolders. The problem was that my assumption was that the includes was rooted on the sources folder, but in reality it's rooted on the project root folder (this can be configured).

    So changing the paths to be absolute from the root fixed them problem.