Can we have multiple projects in a single SonarQube Project

Hi Team,

We have 50+ lightweight dotnet project resides in a single github repo. we have created custom logic in the yml file to build the projects when we run the pipeline.

my question is, is there any way we can maintain 50 + projects in a single sonrqube project.

Hi,

With other languages, you could do this. Unfortunately, a limitation of the SonarScanner for .NET is that one build == one SonarQube project.

If you’re running a commercial edition, you could pull these little projects back together in an Application.

 
HTH,
Ann

@ganncamp we are using enterprise edition and we are already using the Application feature jest checked to know if there is any feature so that we can avoid the overhead of maintaining 50 + projects in SonarQube.

So jest to clarify if i am using standalone scanner or scanning java projects is it possible ?

Hi,

Actually… this may be possible with .NET too. Let us come back to you on that.

And while yes, it’s possible with the other scanners, you can’t analyze .NET code with the other scanners.

 
Ann

@mail2seban

The scanner supports building multiple solutions/MSBuild projects between begin and end. All of the results will be pushed to a single Sonar project e.g.

begin
build solution/ MSBuild project 1 
build solution/ MSBuild project 2
etc ...
end

If I remember correctly, it is also possible to push results to multiple Sonar project from a single pipeline e.g.

begin
build solution 1
end  // -> push results to Sonar project A

... 

begin
build solution 2
end  // -> push results to Sonar project B

There are two main limitations that I can think of. The first is imposed by SonarQube/SonarCloud, which do not support partial analyses of a Sonar project i.e. when you push analysis results to the server, it completely replaces the results from the previous analysis. So you have to push all the data for a Sonar project in one go.

The second limitation is on the SonarScanner for .NET side, which is that it assumes that everything between the begin and end is built as part of a single agent job i.e. one a single machine under a common root directory. The scanner doesn’t support building/testing in parallel on multiple machines and then combining the results before pushing them to the server.

Hi @duncanp We can consider this ms build as entirely separate and each folder has its own sln file for building. for maintainability they are keeping in single repo

@mail2seban I am not clear about what you are asking.

If you want to analyze fifty C# projects and push the results to a single Sonar project, you would have to build them in a single pipeline on a single agent as follows:

begin
build solution 1 
build solution 2
etc ...
build solution 50
end

Does that answer your question?

Hi @Duncan,

How our pipeline is we have 50 projects in a single repository each folder is considered as a single project. We have a yml file outside the folders which is applicable for all the projects. if we need to build 2 project we will go to azure devops pipeline and select project name which is parameterized.

Each project will run in separate jobs.

So what happens is as we are giving same project key results in sonarqube is replaced by recent build one.

Hope the scenario is clear

Thanks,
Sebastian Peter

Hi @mail2seban,

Ok, that’s clearer. You would need to parameterise the Sonar project key too so that each MSBuild project has a separate Sonar project key (either using the project parameter directly, or calculating the Sonar project key from it).

Yep lm able to dynamically pass the project key. Jest wondering if its possible to incorporate in a single sonarqube project so that we can avoid the overhead of maintaining multiple projects.

No - you’ll hit the Sonar server limitation mentioned above:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.