I have azure pipeline to build my project code on Ubuntu 22.0 log_files.zip (3.8 MB)
4 agent using gcc-arm-none-eabi-10.3-2021.10 compiler. I am in process to extend my pipeline to add sonarqube scanner. capabilities
I followed below steps:
In Azure DevOps make Build Wrapper available on the build agent.
curl ‘{SonarQube URL}/static/cpp/build-wrapper-linux-x86.zip’ --output build-wrapper.zip
unzip build-wrapper.zip
Added a new Prepare Analysis Configuration task before the build task.
Modifed existing build bash task with wrapper
chmod +x build-wrapper-linux-x86/build-wrapper-linux-x86-64
build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output make clean all
(Note, i added chmod as i was getting error - permission denied for build wrapper)
Added a new Run Code Analysis task after the build task
I see build-wrapper-dump.json and build-wrapper.log is generated ( these files are not empty, and says 780 files are scanned). However, in run code analysis stage i get below error-
< ##[error]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
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:494)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:215)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:64)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:88)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:64)
at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(SpringModuleScanContainer.java:82)/>
I am using
Sonarqube version 5.17.2
SonarScanner version 4.8.1.3023
Build-wrapper-linux-x86-64
I am lost why is scanner failing here specially when the build-wrapper.jason file is generated.
Couple of questions,
Is build-wrapper-linux-x86-64 compatible to run on ubuntu 20.4 ?
How can i check if build-wrapper.jason file collected the information ? When i see this file i see all my files. so now wondering why scanner complaining on 0 c/c++ files were analyzed.
I am really stuck here so any help would be greatly appreciated,
I had a look at the collected information in the build-wrapper dump you shared, and nothing looks suspicious there. I can also confirm that build-wrapper supports Ubuntu 20.4.
As the issue seems to happen during the scan, could you please share with us the full verbose scanner logs? The verbose logs can be obtained by adding any of -X , --verbose , or -Dsonar.verbose=true to your scanner command.
Attached is the log for your reference Scanner_log.txt (23.0 KB)
.
I am really lost why the scanner is failing.
Please can you have a look and provide some suggestion.
Just for your info, the scanner is being called automatically from Run Code Analysis step from Azure DevOps as it connects with our organization server for sonarqube.
DEBUG: 's/wdp-hermes-app/Main.cpp' indexed with language 'cpp'
^^
Whereas, the build-wrapper dump json file references wdp-hermes-app/./Main.cpp without the s/ directory at the beginning.
Do you know where this extra s/ directory in the scanner environment comes from? Note that the paths of the files need to be identical while scanning and building in order for the scanner to use the information recoded during the wrapped build.
It was indeed the issue with the path for the scanner.
I always thought the scanner and wrapper were running via /home/vsts/work/1.
As you pointed out scanner was buried under the main directory from debug log. Now that i have moved scanner to run at the root directory in Prepare analysis Configuration step, Scanner execution was successful.
I was kind of stuck with this issue.
Thank you so much for your help.