Error during SonarQube Scanner execution - C, C++ and C# Code

SonarQube Version: 7.9.1
SonarQube Scanner 4.1.0.1829
SonarScanner for MSBuild 4.7.1

I am trying to perform SonarQube scan on a product that has C, C++ and C# code. I have followed all the standard instructions to set up scanning in a Jenkins job but seeing failures.

 17:07:19 ERROR: Error during SonarQube Scanner execution
17:07:19 java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
17:07:19   * you are using the latest version of the build-wrapper and the SonarCFamily analyzer
17:07:19   * you are correctly invoking the scanner with correct configuration  * your compiler is supported
17:07:19   * you are wrapping your build correctly
17:07:19   * you are wrapping a full/clean build
17:07:19   * you are providing the path to the correct build-wrapper output directory
17:07:19   * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
17:07:19 	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:357)
17:07:19 	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
17:07:19 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
17:07:19 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
17:07:19 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
17:07:19 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
17:07:19 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
17:07:19 	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
17:07:19 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
17:07:19 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
17:07:19 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
17:07:19 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
17:07:19 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
17:07:19 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
17:07:19 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
17:07:19 	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
17:07:19 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
17:07:19 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
17:07:19 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
17:07:19 	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
17:07:19 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
17:07:19 	at java.lang.reflect.Method.invoke(Unknown Source)
17:07:19 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
17:07:19 	at com.sun.proxy.$Proxy0.execute(Unknown Source)
17:07:19 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
17:07:19 	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
17:07:19 	at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
17:07:19 	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
17:07:19 	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
17:07:19 ERROR: 
17:07:19 The SonarQube Scanner did not complete successfully
17:07:19 06:37:19.985  Post-processing failed. Exit code: 1
17:09:18 ERROR: Execution of SonarScanner for MSBuild failed (exit code 1)

For the C# code, I am seeing these errors prior to the above-mentioned failure -

I should add that the Jenkins build uses junctions/symbolic links to reference some files. This is something which we won’t be able to avoid.

Hello @gischethans

Can you share the build-wrapper-dump.json and build-wrapper.log files? Also I will need the full output of the sonar-scanner in debug mode. Let me know if you prefer to share them privately.

Thanks,

Hi @Abbas, I would prefer to share them privately. How do I do that?

@gischethans, I sent you a private message

I have replied to your private message, @Abbas. Thank you!

@gischethans, thanks for sharing the log files. I had a look, it seems that you have only 3 C++ files and they are all compiled with /clr. CLR isn’t supported and files that are using it are skipped. That is why you ended up with 0 files analyzed.

  • If you are not using CLR you can remove the flag and the analysis should work.
  • If you are using/need CLR for all files, the C++ analyzer cannot analyze your files and shouldn’t be enabled.

Thanks,

1 Like