Can I build multiple solutions and push the results into one Sonarqube project?


Sonarqube Edition & Verison - Data Center Edition / 9.6.1

I am trying to understand whether there is a way to build multiple solutions that contain both C++ and C# code and push that result into a Single Sonar Project.

Previously, When using Community Edition, We used to run the BEGIN step(with the project key) and using MSBuild, build all the solutions(one-by-one) and run the END step. (We run the scan this way using a bat file).

Now, since C++ can be scanned in the Data Center Edition using the build wrapper, we tried to include the buildwrapper into our .bat file as it is mentioned here, C/C++/Objective-C | SonarQube Docs

But the problem here is, the buildwrapper-output.json that is being generated in each build is getting overwritten every time when the next solution is built.

I would really appreciate any suggestions on whether the current way we are running it is correct/is there an appropriate way to run this to cover all the c++ files and get an accurate result.

Thank you in advance!!!

Hello @aravindnss and welcome to our community.

It seems you are doing something like:

BEGIN STEP (with /<buildwrapperoutput_directory>)
for each solution to build
  build-wrapper --out-dir <buildwrapperoutput_directory> <msbuild rebuild command for solution>

Instead, you should have a script with

for each solution to build
  <msbuild rebuild command for solution>

And then, you should do the following:

BEGIN STEP (with /<buildwrapperoutput_directory>)
  build-wrapper --out-dir <buildwrapperoutput_directory> script

Does it help?

Hi @Geoffray,

Apologies for the late response and thank you so much for your reply.

I did try running it the way you suggested but I get the following error saying the BuildWrapperDump.json is empty.

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found empty. Please make sure that:
  * you are using the latest version of the build-wrapper and the CFamily analyzer
INFO: ------------------------------------------------------------------------
  * your compiler is supported
  * you are wrapping your build correctly
  * you are wrapping a full/clean build
  * if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process
        at com.sonar.cpp.plugin.CFamilySensor.process(
        at com.sonar.cpp.plugin.CFamilySensor.execute(
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
        at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.batch.bootstrapper.Batch.doExecute(
        at org.sonar.batch.bootstrapper.Batch.execute(
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.base/java.lang.reflect.Method.invoke(
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.main(
The SonarScanner did not complete successfully

Let me know if there are any more details you want me to share.

Thanks again for helping me with this!

Hi @Arvinder_Chopra

Are you sure you are doing a clean build (a rebuild)?
So your entire build is done in one script which is passed to the build wrapper?
Are you using docker containers to build?

Hi @Geoffray,

I missed the rebuild part, but after adding that I could run the scan successfully.

Thank you so much for your help :slight_smile:

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