Sonar analysis is failing for bazel build on windows

Running SonnarScanner for a C++ project on windows. It uses bazel for compilation .
This is the command for build:
build-wrapper-win-x86-64.exe --out-dir C:\sonartools\buildwrapper-ouput bazel --batch build --spawn_strategy=standalone --genrule_strategy=standalone //source/ztna/ZtnaAgentLib/…

this is the command for analysis:
sonar-scanner -Dproject.settings=C:\sonartools\ztna_sonar-project.properties

content of the file

sonar.projectKey=
sonar.login=
sonar.projectVersion=1.0
sonar.cfamily.cache.enabled=false
sonar.projectBaseDir=
sonar.sources=source/ztna/ZtnaAgentLib
sonar.cfamily.build-wrapper-output=C:/sonartools/buildwrapper-ouput

It creates the analysis json file, detail is attached but the analysis is failing with the error below

ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • you are correctly invoking the scanner with correct configuration
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • you are providing the path to the correct build-wrapper output directory
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
    attaching the zip file for details.
    sonarscannererror.zip (72.0 KB)

Appreciate any help here

Hi,

Welcome to the community!

This thread may help:

 
HTH,
Ann

Hi @ganncamp ,
The same arguments as above are passed for building and json file creation is fine. Scanning is failing.
Regards,
Madan

We use a test license for sonar server, is that an issue ?

Any update here ?
Any suggestion or alternative we can try from our end ?

Hi @Madan,

  • From which directory are you running the scanner? it should be run from a directory that contains the file that you are building with build-wrapper.
  • Why are you adding this? can you remove it?
  • What compiler are you using?

spawn_strategy=standalone --genrule_strategy=standalone

  • standalone is deprecated, try to use local instead
 --spawn_strategy=local
 --strategy=Genrule=local
  • If the analysis is still failing after applying all the suggestions, Can you share your build-wrapper JSON and log files in addition to the scanner output in verbose mode. I can send you a private message if you prefer to send them privately.

Thanks,

Thanks Abbas,
Have tried with above suggested options , but still I see the same error.
Please send me a private message to shared the requested data privately.
Regards,
Madan

Hello @Madan,

Thanks for the log.
Before I give it a deeper look can you try on the latest LTS: SonarQube 8.9.8 LTS.

We fixed similar issues on that version and it might work for you.

Let me know if you still face the issue after.

Thanks,

1 Like

A post was split to a new topic: Setup analysis of bazel project

Hi @Madan,

Were you able to try with the latest release?

Thanks,