Running SonarQube analysis scan - SonarSource build-wrapper

DoruF picture DoruF · Nov 22, 2016 · Viewed 13.4k times · Source

I'm new to running SonarQube scans and I get this error message in the log in Jenkins:

16:17:39 16:17:36.926 ERROR - The only way to get an accurate analysis of your C/C++/Objective-C project is by using the SonarSource build-wrapper. If for any reason, the use of the build-wrapper is not possible on your project, you can bypass it with the help of the "sonar.cfamily.build-wrapper-output.bypass=true" property. By using that property, you'll switch to an "at best" mode that could result in false-positives and false-negatives.

Can someone please advise where I can find and run this SonarSource build-wrapper?

Thanks a lot for your help!

Answer

Abhijeet Kamble picture Abhijeet Kamble · Jul 26, 2017

To solve this issue, download the Build Wrapper directly from your SonarQube Server, so that its version perfectly matches your version of the plugin:

Build Wrapper for Linux can be downloaded from URL

http://localhost:9000/static/cpp/build-wrapper-linux-x86.zip

Unzip the downloaded Build Wrapper, Configure it in your PATH because it's just more convenient

export PATH=$PATH:/path/where/you/unzip

Once done, Run below commands.

build-wrapper-linux-x86-64 --out-dir <dir-name> <build-command>
build-wrapper-linux-x86-64 --out-dir build_output make clean all

Once all this done, you have to modify your sonar-project.properties file with following line. Note the dir-name is same directory which we defined in previous command.

sonar.cfamily.build-wrapper-output=<dir-name>

and then you can run the sonar scanner command.

sonar-scanner

this will do the analysis against your code. For more details, you can check this link.