Hi, I’m using SonarCloud in via CircleCI workflow. My project is based on C++, here are the info:
ALM used: GitHub
CI system used: Circle CI
Languages of the repository: C++
Compiler: gcc and mpicc
Error observed:
ERROR: Error during SonarQube Scanner 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.execute(CFamilySensor.java:439)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:45)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:68)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:440)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:436)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:394)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:126)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Exited with code exit status 1
CircleCI received exit code 1
drwxrwxr-x 5 pruiz pruiz 4096 ene 14 20:10 ./
drwxrwxrwt 28 root root 57344 ene 14 20:23 ../
-rw-rw-r-- 1 pruiz pruiz 3292 ene 14 18:36 arbol.cpp
-rw-rw-r-- 1 pruiz pruiz 1376 ene 14 18:36 arbol.h
-rw-rw-r-- 1 pruiz pruiz 223968 ene 14 20:10 arbol.o
drwxrwxr-x 2 pruiz pruiz 4096 ene 14 20:10 build_wrapper_output_directory/
drwxrwxr-x 2 pruiz pruiz 4096 ene 14 20:09 .circleci/
-rw-rw-r-- 1 pruiz pruiz 605 ene 14 18:36 .deepsource.toml
drwxrwxr-x 8 pruiz pruiz 4096 ene 14 20:09 .git/
-rw-rw-r-- 1 pruiz pruiz 40 ene 14 18:38 .gitignore
-rw-rw-r-- 1 pruiz pruiz 1067 ene 14 18:36 LICENSE
-rw-rw-r-- 1 pruiz pruiz 3434 ene 14 18:36 main.cpp
-rw-rw-r-- 1 pruiz pruiz 180744 ene 14 20:10 main.o
-rw-rw-r-- 1 pruiz pruiz 309 ene 14 18:36 Makefile
-rwxrwxr-x 1 pruiz pruiz 214496 ene 14 20:10 mpiDisc*
-rw-rw-r-- 1 pruiz pruiz 7250 ene 14 18:36 raid.cpp
-rw-rw-r-- 1 pruiz pruiz 907 ene 14 18:36 raid.h
-rw-rw-r-- 1 pruiz pruiz 217728 ene 14 20:10 raid.o
-rw-rw-r-- 1 pruiz pruiz 82 ene 14 19:07 README.md
-rw-rw-r-- 1 pruiz pruiz 1563 ene 14 18:36 slave.cpp
-rw-rw-r-- 1 pruiz pruiz 539 ene 14 18:36 slave.h
-rw-rw-r-- 1 pruiz pruiz 193016 ene 14 20:10 slave.o
-rw-rw-r-- 1 pruiz pruiz 1432 ene 14 19:52 sonar-project.properties
-rw-rw-r-- 1 pruiz pruiz 22436 ene 14 18:36 terminal.cpp
-rw-rw-r-- 1 pruiz pruiz 2039 ene 14 18:36 terminal.h
-rw-rw-r-- 1 pruiz pruiz 250112 ene 14 20:10 terminal.o
Current sonar-project.properties:
sonar.projectKey=Pitenager_Distributed_Systems
sonar.organization=pitenager
# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=Distributed_Systems
sonar.projectVersion=1.0
sonar.cfamily.build-wrapper-output=build_wrapper_output_directory
sonar.cfamily.threads=5
# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.
# Encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8
Thank you for your quick answer, this is the full trace:
#!/bin/bash -eo pipefail
set -e
VERSION=4.1.0.1829
SONAR_TOKEN=$SONAR_TOKEN
SCANNER_DIRECTORY=/tmp/cache/scanner
export SONAR_USER_HOME=$SCANNER_DIRECTORY/.sonar
OS="linux"
echo $SONAR_USER_HOME
if [[ ! -x "$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner" ]]; then
curl -Ol https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-$VERSION-$OS.zip
unzip -qq -o sonar-scanner-cli-$VERSION-$OS.zip -d $SCANNER_DIRECTORY
fi
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
chmod +x $SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/jre/bin/java
$SCANNER_DIRECTORY/sonar-scanner-$VERSION-$OS/bin/sonar-scanner
/tmp/cache/scanner/.sonar
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 40.4M 100 40.4M 0 0 11.2M 0 0:00:03 0:00:03 --:--:-- 11.2M
INFO: Scanner configuration file: /tmp/cache/scanner/sonar-scanner-4.1.0.1829-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: /root/project/sonar-project.properties
INFO: SonarQube Scanner 4.1.0.1829
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Linux 4.15.0-1077-aws amd64
INFO: User cache: /tmp/cache/scanner/.sonar/cache
INFO: SonarQube server 8.5.0
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Load global settings
INFO: Load global settings (done) | time=579ms
INFO: Server id: 1BD809FA-AWHW8ct9-T_TB3XqouNu
INFO: User cache: /tmp/cache/scanner/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=152ms
INFO: Load/download plugins (done) | time=26079ms
INFO: Loaded core extensions: developer-scanner
INFO: JavaScript/TypeScript frontend is enabled
INFO: Found an active CI vendor: 'CircleCI'
INFO: Load project settings for component key: 'Pitenager_Distributed_Systems'
INFO: Load project settings for component key: 'Pitenager_Distributed_Systems' (done) | time=105ms
INFO: Process project properties
INFO: Execute project builders
INFO: Execute project builders (done) | time=2ms
INFO: Project key: Pitenager_Distributed_Systems
INFO: Base dir: /root/project
INFO: Working dir: /root/project/.scannerwork
INFO: Load project branches
INFO: Load project branches (done) | time=101ms
INFO: Check ALM binding of project 'Pitenager_Distributed_Systems'
INFO: Detected project binding: BOUND
INFO: Check ALM binding of project 'Pitenager_Distributed_Systems' (done) | time=99ms
INFO: Load project pull requests
INFO: Load project pull requests (done) | time=104ms
INFO: Load branch configuration
INFO: Auto-configuring branch main
INFO: Load branch configuration (done) | time=4ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=145ms
INFO: Load active rules
INFO: Load active rules (done) | time=3155ms
INFO: Organization key: pitenager
INFO: Branch name: main, type: long living
INFO: Indexing files...
INFO: Project configuration:
INFO: 23 files indexed
INFO: 0 files ignored because of scm ignore settings
INFO: Quality profile for c: Sonar way
INFO: Quality profile for cpp: Sonar way
INFO: ------------- Run sensors on module Distributed_Systems
INFO: JavaScript/TypeScript frontend is enabled
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=126ms
INFO: Sensor SonarCSS Rules [cssfamily]
INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=0ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor JavaXmlSensor [java]
INFO: Sensor JavaXmlSensor [java] (done) | time=0ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=2ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=1ms
INFO: Sensor CFamily [cpp]
INFO: CFamily plugin version: 6.16.0.26112
INFO: Using build-wrapper output: /root/project/build_wrapper_output_directory/build-wrapper-dump.json
INFO: Available processors: 10
INFO: Using 5 threads for analysis according to value of "sonar.cfamily.threads" property.
INFO: Load project repositories
INFO: Load project repositories (done) | time=108ms
WARN:
CFamily plugin supports incremental analysis with the use of a cache:
* if you do not want to enable cache
please explicitly disable it
by setting the following property to your analysis:
sonar.cfamily.cache.enabled=false
* to enable cache please specify the following 2 options:
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location
* visit the documentation page for more information
https://sonarcloud.io/documentation/analysis/languages/cfamily/
INFO: PCH: unique=0 use=0 (forceInclude=0,throughHeader=0,firstInclude=0) out of 0 (forceInclude=0,throughHeader=0)
INFO: Subprocess(es) done in 15ms
INFO: 0 compilation units analyzed
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 40.039s
INFO: Final Memory: 25M/87M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner 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.execute(CFamilySensor.java:439)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:45)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:68)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:440)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:436)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:394)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:126)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
at com.sun.proxy.$Proxy0.execute(Unknown Source)
at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Exited with code exit status 1
CircleCI received exit code 1
the issue comes from the fact that the build and analysis are done on two different paths. In the build-wrapper-dump.json file I can see that built files are in /tmp/Distributed_Systems folder.
In the log analysis I see that sonar-scanner is running in /root/project.
The analysis should happens in the same environment of the build and on the same checkout, with the same absolute paths.
you are building your project locally and trying to analyze it on Circle CI.
You are supposed to both build it and analyze it on Circle CI, build_wrapper_output_directory should be generated on the same environment of the analysis, hence on Circle CI.
Your .circleci/config.yml should looks something like (notice the Build step):