We recently purchased Sonarqube developer edition. After preliminary testing, we ran Sonarqube for a set of packages in one of our product. In this, Sonarqube scanner step is continuously failing for a package ‘sam’ (C/C++). Please find below the steps that we used for the Sonarqube analysis:
Client:
build-wrapper, version 6.15 (linux-x86)
SonarScanner 4.5.0.2216
Server:
Developer Edition Version 8.6.1
Steps:
cd /code/monitoring/sam (Package path under which the Makefile exists)
/opt/sonarqube/bin/build-wrapper-linux-x86-64 --out-dir /output/ make RELEASE=true ROOT=/code/buildroot P4CHANGENUM=100000 [SUCCESS]
[2021-02-20T15:03:04.191Z] ERROR: Error during SonarScanner execution
[2021-02-20T15:03:04.191Z] java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed.
Note: Sonarqube analysis is done inside Centos 7 docker container.
When I checked the ‘/output/build-wrapper-dump.json’ file, I am able to see the C/C++ file analysis information for the ‘sam’ package. Can anyone help me in identifying this issue?
Hi @balamurugan.r, welcome to the SonarSource Community!
This stands out to me as a likely source of your problem. The analysis must be conducted on the same host used for the wrapped build; mismatches in paths on the host environments often prevent us from identifying files seen during the build as “the same” as files encountered by the analyzer and leads to your error.
Both the commands ‘build-wrapper-linux-x86-64’ and ‘sonar-scanner’ are run inside the same container environment and inside the same path (successively in the same shell session).
Steps (All steps are run inside the Centos 7 container where the source code path is mounted):
cd /code/monitoring/sam (Package path under which the makefile exists)
/opt/sonarqube/bin/build-wrapper-linux-x86-64 --out-dir /output/ make RELEASE=true ROOT=/code/buildroot P4CHANGENUM=100000 [SUCCESS]
For successful analysis, it’s best if all the code is organized to live within a common parent directory, that the build-wrapper and sonar-scanner both be invoked from this directory, and that this is where the sonar-project.properties lives.
Yeah I understand @Jeff_Zapotoczny but these other directories like ‘cpp-libs’ are common library paths used by multiple packages across multiple repositories. The problem here is for other packages with similar conditions, the sonar-analysis ran successfully but is failing only for this package. Even when the C/C++ code is analysed and its information is there in ‘/output/build-wrapper-dump.json’ file, sonar-scanner is failing with an error “build-wrapper-dump.json file was found but 0 C/C++/Objective-C files were analyzed.” . I couldn’t understand why this error is popping when the C/C++ files are analysed successfully.