ERROR: Error during SonarQube Scanner execution java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found empty

Hello,

I´m using SonarQube Scanner to analyze my code. Everything worked fine and the analysis was uploaded to Sonarcloud, but since last week I am getting this error:

ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty.

The code should be analysed locally with the commands:

  • build-wrapper-win-x86-64.exe --out-dir bw-output make clean all
  • sonar-scanner.bat -D"sonar.projectKey=$PROJECTKEY" -D"sonar.organization=$ORGANIZATION" -D"sonar.sources=./src/ARYA/src" -D"sonar.cfamily.build-wrapper-output=bw-output" -D"sonar.host.url=https://sonarcloud.io" -D"sonar.login=$SONAR_TOKEN"

where $SONAR_TOKEN is my created token at sonarcloud.io -> myAccount.

In both, locally and via remote bitbucket Pipeline testing, I always get that error message. Even after going back to the latest commit where the analysis ran perfectly and was uploaded to sonarcloud, the analysis still fails.

Did something change in SonarQube?
I´m using the latest version of SonarScanner which should be 4.0.0.1744 and, as far as I know, the latest version of the build-wrapper.

When comparing the logs of the bitbucket-pipeline after it was succesful with the log of a pipeline that failed, there is just one difference. In the failed analysis the scanner succesfully loads a repository and after that the same warnings appear (which can also be seen in local testing). Then the execution failes:

Do you have any idea, what I am possibly missing?

Thanks!

Hi @The_Cempion,

we added this safety check on latest release, this means that before you were not getting any c/c++ file correctly analyzed, now we are failing if it is the case to help you get a better analysis.

The error means that the build-wrapper-dump.json file found inside bw-output folder is found empty.

What compiler are you using?

Hi Massimo,

thank you for replying. I am using GCC-Compiler.

Hi @The_Cempion,

Could you please get the bw_output folder content from your build and share it? If it contains private data I can send you a PM where you can safely share it.

Do you mean the build-wrapper.log and build-wrapper-dump.json?

Hi @The_Cempion,

yes!

Build-wrapper.log

Wed Oct 02 11:29:01 2019: build-wrapper, version 6.3 (win-x86-64)
Wed Oct 02 11:29:01 2019: isWow64: 0
Wed Oct 02 11:29:01 2019: windows version: 6.2, service pack: 0.0, build number: 9200, product type: 1
Wed Oct 02 11:29:01 2019: current directory: C:\Users\cemci\RepoRecalm\firmware
Wed Oct 02 11:29:01 2019: command line received:
Wed Oct 02 11:29:01 2019: initializing json file
Wed Oct 02 11:29:01 2019: starting debug cycle
Wed Oct 02 11:29:01 2019: process created with pid: 1184
Wed Oct 02 11:29:01 2019: image path name: <C:\msys64\usr\bin\make.exe>
Wed Oct 02 11:29:01 2019: command line:
Wed Oct 02 11:29:01 2019: working directory: <C:\Users\cemci\RepoRecalm\firmware>
Wed Oct 02 11:29:01 2019: isWow64: 0
Wed Oct 02 11:29:01 2019: skipping process C:\msys64\usr\bin\make.exe with pid: 1184
Wed Oct 02 11:29:01 2019: process with pid 1184 exit with code: 2 (0x2)
Wed Oct 02 11:29:01 2019: finalizing json file

build-wrapper-dump.json

#© SonarSource SA, 2014-2019, info@sonarsource.com
#All SONARSOURCE programs and content are copyright protected.
#SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.

#This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
#It may not be used in connection with any other software.
#Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
“version”:0,
“captures”:[
]}

Hi @The_Cempion,

it seems that your build is not succeeding given the exit code, could you make sure that you are getting a successful build?

Hi @mpaladin,

Well, I just tried again to get a build, but all the same.

I always get the same error message at the excat same point in analysis. I didn´t change anything at all and the code to be checked wasn´t changed as well. How is it possible, that the analysis failes, when it ran perfectly fine? And why does it load the repository? I don´t get it.

Hi @The_Cempion,

the build is failing, what is the output of build-wrapper-win-x86-64.exe --out-dir bw-output make clean all? Its exit status is 2, which means something goes wrong.

Hi @mpaladin,
its output says: make: *** No rule to make target ‘clean’. Stop.
But that´s the output I´ve always gotten, because it is not defined yet. Then I entered the second command and usually the code was scanned, but now it failes execution.

Hi @The_Cempion,

it means that you don’t have clean defined in your Makefile. I invite you to first master your build before trying to setup an analysis, and on that, I cannot help you much.

No, the code was not scanned properly, that’s why we added this check.

Okay, I´ll try my best, thank you.

Hi @The_Cempion,

great, keep me posted once you managed to fix your build.

1 Like

Hi @mpaladin,
I am trying to get a build, but so far I didn´t. Isn´t “make clean all” supposed to get me a correct build, or did I misunderstand something? If the latter is the case: Do I need to write my own makefile?

Hi @The_Cempion,

how do you usually build your project?

Now I am using MSbuild, but usually it should be build with xilinx sdk 2018.3

If you are using msbuild you certainly wouldn’t be able to build it with make.

Hi @mpaladin
I know. Usually I´ve used make but then i tried downloading msbuild and using it instead with the command MSBuild.exe instead of make clean all. But that does not change the fact that in my bitbucket Pipeline the build was succesfully checked but the analysis wasn´t. In the bitbucket Pipeline i am using a docker Image with Ubuntu 18.04.
And why does my pipeline needs to load my repositories? Where can I set that property?