The project is based on Keil environment

Hi Team,

we are interested in doing analysis using Sonar cloud.

Our project is purely hardware dependent , but the software which is written using C program.

we have created the piepline in Azure devops , but run code analysis using soanrcloud
is through the error as below

##[error]The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects. --> we don’t have MSbuild.
(how the sonar cloud will support for other build and how to configure it?)

Please give us some suggestion or input.

Hi @Kodeeswaran_west,

if you have only C/C++ code, I would recommend you to use sonar-scanner and follow the documentation to analyze C/C++ code: https://docs.sonarqube.org/latest/analysis/languages/cfamily/.

However, what compiler are you precisely using? Please make sure it appears in the list of supported compilers.

Hi @mpaladin,

Thanks for your reply…

we are using ARM5 compiler(armcc) and the IDE is Keil.

I have gone through the document , need the clarification on Analysis steps topic.
It is mentioned that when we not using MSbuild.exe follow the steps for windows

// example for Windows
build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory **MSBuild.exe /t:Rebuild**

still msbuild.exe is present in the command execution. Please clarify this one.

Also is there any step by step procedure for ARM5 compiler steps.

Hi @Kodeeswaran_west,

:+1:

You should do:

build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory  my_build_command

where my_build_command can be any command, i.e.:

make clean install
msbuild /t:rebuild
my_custom_builder.exe
bash myscript.sh
...

Hi @mpaladin,

Sorry to ask you this.

I am not good in writing sheel script. Can you provide some good forum to learn this?

it will be useful for me…

or if any documents for this as well as for sonar-scanner please share it

Hi @Kodeeswaran_west,

before talking about analyzing the project, do you have CI for your project? How are you building your project from command line?

Hi @mpaladin,

https://www.keil.com/support/man/docs/uv4/uv4_commandline.htm --> this link provides the commands on how to execute the keil project. with the help of this I have written the step by step commands in build agent of task in Azure devops.

I can able to write or manage the script if the things are straight forward.

Hi @Kodeeswaran_west,

before considering analyzing the project get your project to build from command line, once that will be successful it is going to be easy to add the analysis.

Hi @mpaladin,

My build is getting successful without any error using command line, but during analysis only I am facing the error which is mentioned in my first post( MSbuild issue)

please give me some suggestion on this.

Hi @Kodeeswaran_west,

as written above you should follow the documentation for sonar-scanner, you should do something like:

build-wrapper-win-x86-64.exe --out-dir  build_wrapper_output_directory  my_clean_build_command

sonar-scanner

Hi @mpaladin,

how can I link my_clean_build_command here?

Hi @mpaladin,

Directly I used your command in the command prompt, the error attached in the image above.Later I realized that I have to provide the path for build_wrapper_output_directory(referred some path) and my_clean_build_command (i have CLI command as .bat file, so provided that path)

it is working partially. My doubt is providing .bat file path is it correct?

and how to execute sonar-scanner in command prompt?

Thanks in advance.

Hi @mpaladin,

able to manage and execute the command which you have provided(still with .bat file)

i am getting below errors:

INFO: Project root configuration file: NONE
INFO: SonarScanner 4.4.0.2170
INFO: Java 11.0.3 AdoptOpenJDK (64-bit)
INFO: Windows 10 10.0 amd64
INFO: User cache: C:\Users\sivaprakasak.sonar\cache
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 5:00.657s
INFO: Final Memory: 3M/17M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:85)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:74)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.createLauncher(IsolatedLauncherFactory.java:70)
at org.sonarsource.scanner.api.EmbeddedScanner.doStart(EmbeddedScanner.java:185)
at org.sonarsource.scanner.api.EmbeddedScanner.start(EmbeddedScanner.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:73)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.lang.IllegalStateException: Fail to get bootstrap index from server
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:42)
at org.sonarsource.scanner.api.internal.JarDownloader.getScannerEngineFiles(JarDownloader.java:58)
at org.sonarsource.scanner.api.internal.JarDownloader.download(JarDownloader.java:53)
at org.sonarsource.scanner.api.internal.IsolatedLauncherFactory.lambda$createLauncher$0(IsolatedLauncherFactory.java:76)
… 7 more
Caused by: java.net.SocketTimeoutException: timeout
at org.sonarsource.scanner.api.internal.shaded.okio.Okio$4.newTimeoutException(Okio.java:232)
at org.sonarsource.scanner.api.internal.shaded.okio.AsyncTimeout.exit(AsyncTimeout.java:286)
at org.sonarsource.scanner.api.internal.shaded.okio.AsyncTimeout$2.read(AsyncTimeout.java:241)
at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource.read(RealBufferedSource.java:51)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$AbstractSource.read(Http1ExchangeCodec.java:389)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.http1.Http1ExchangeCodec$UnknownLengthSource.read(Http1ExchangeCodec.java:529)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.connection.Exchange$ResponseBodySource.read(Exchange.java:286)
at org.sonarsource.scanner.api.internal.shaded.okio.RealBufferedSource.select(RealBufferedSource.java:100)
at org.sonarsource.scanner.api.internal.shaded.okhttp.internal.Util.bomAwareCharset(Util.java:467)
at org.sonarsource.scanner.api.internal.shaded.okhttp.ResponseBody.string(ResponseBody.java:181)
at org.sonarsource.scanner.api.internal.ServerConnection.downloadString(ServerConnection.java:100)
at org.sonarsource.scanner.api.internal.BootstrapIndexDownloader.getIndex(BootstrapIndexDownloader.java:39)
… 10 more
Caused by: java.net.SocketTimeoutException: Read timed out
at java.base/java.net.SocketInputStream.socketRead0(Native Method)
at java.base/java.net.SocketInputStream.socketRead(Unknown Source)
at java.base/java.net.SocketInputStream.read(Unknown Source)
at java.base/java.net.SocketInputStream.read(Unknown Source)
at org.sonarsource.scanner.api.internal.shaded.okio.Okio$2.read(Okio.java:140)
at org.sonarsource.scanner.api.internal.shaded.okio.AsyncTimeout$2.read(AsyncTimeout.java:237)
… 19 more
ERROR:
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Please suggest what I am doing wrong? also how to edit sonar-scanner.properties?

Thank you…

Hi @Kodeeswaran_west,

you should properly configure the sonar host url and login/password properties and make sure you can reach the server.

Hi @mpaladin,

I am doing this from desktop( all keil projects and sonar-scanner in desktop) , Sonar-scanner.properties is available in the following path c:\test;\sonar-scanner-4.4.0.2170-windows\conf\ and edited my properties file as below.

sonar.projectKey=Key
sonar.projectName=C_Analysis
sonar.projectVersion=1.0
sonar.sources=C:\Kodeeswaran\src
sonar.cfamily.build-wrapper-output=C:\Desktop\Gcc
sonar.sourceEncoding=UTF-8

is I am missing anything ?
Please guide me on this.

Hi @Kodeeswaran_west,

the error says that it cannot reach the SonarQube server, please check the configuration. See https://docs.sonarqube.org/latest/analysis/analysis-parameters/:

sonar.host.url
sonar.login
sonar.password

Hi @mpaladin,

How to configure Server side?

Hi @Kodeeswaran_west,

please follow the SonarCloud tutorial to configure and analyze your project.

Hi @mpaladin,

Getting following error,

If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:

sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

2020-08-27T09:53:59.3108980Z ERROR:
2020-08-27T09:53:59.3109237Z
2020-08-27T09:53:59.3109918Z The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
2020-08-27T09:53:59.3110590Z and setting the property “sonar.cfamily.build-wrapper-output”, but it was not specified.
2020-08-27T09:53:59.3110963Z
2020-08-27T09:53:59.3111533Z If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
2020-08-27T09:53:59.3112043Z
2020-08-27T09:53:59.3113268Z sonar.c.file.suffixes=-
2020-08-27T09:53:59.3113605Z sonar.cpp.file.suffixes=-
2020-08-27T09:53:59.3113963Z sonar.objc.file.suffixes=-
2020-08-27T09:53:59.3114190Z
2020-08-27T09:53:59.3114343Z
2020-08-27T09:53:59.3265395Z INFO: ------------------------------------------------------------------------
2020-08-27T09:53:59.3266516Z INFO: EXECUTION FAILURE
2020-08-27T09:53:59.3267979Z INFO: ------------------------------------------------------------------------
2020-08-27T09:53:59.3268773Z INFO: Total time: 2:20.084s
2020-08-27T09:53:59.4555240Z INFO: Final Memory: 28M/78M
2020-08-27T09:53:59.4557783Z ##[error]ERROR: Error during SonarScanner execution
2020-08-27T09:53:59.4560806Z ERROR: Error during SonarScanner execution
2020-08-27T09:53:59.4561378Z INFO: ------------------------------------------------------------------------
2020-08-27T09:53:59.4566910Z ##[error]java.lang.UnsupportedOperationException:

The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
and setting the property “sonar.cfamily.build-wrapper-output”, but it was not specified.

If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:

sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

2020-08-27T09:53:59.4570447Z java.lang.UnsupportedOperationException:
2020-08-27T09:53:59.4570804Z
2020-08-27T09:53:59.4571299Z The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper
2020-08-27T09:53:59.4572081Z and setting the property “sonar.cfamily.build-wrapper-output”, but it was not specified.
2020-08-27T09:53:59.4572501Z
2020-08-27T09:53:59.4573128Z If you don’t want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:
2020-08-27T09:53:59.4573677Z
2020-08-27T09:53:59.4573932Z sonar.c.file.suffixes=-
2020-08-27T09:53:59.4574313Z sonar.cpp.file.suffixes=-
2020-08-27T09:53:59.4574712Z sonar.objc.file.suffixes=-
2020-08-27T09:53:59.4574975Z
2020-08-27T09:53:59.4575229Z
2020-08-27T09:53:59.4577879Z ##[error]at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:145)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:45)
2020-08-27T09:53:59.4581077Z at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:145)
2020-08-27T09:53:59.4593972Z ##[error]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:122)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:419)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:415)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:373)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:126)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
2020-08-27T09:53:59.4601853Z
2020-08-27T09:53:59.4602573Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
2020-08-27T09:53:59.4603605Z at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
2020-08-27T09:53:59.4604646Z at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:68)
2020-08-27T09:53:59.4606708Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
2020-08-27T09:53:59.4607794Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
2020-08-27T09:53:59.4608765Z at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:419)
2020-08-27T09:53:59.4609767Z at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:415)
2020-08-27T09:53:59.4610845Z at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:373)
2020-08-27T09:53:59.4612047Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
2020-08-27T09:53:59.4613074Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
2020-08-27T09:53:59.4614064Z at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:126)
2020-08-27T09:53:59.4615072Z at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:122)
2020-08-27T09:53:59.4616131Z at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:108)
2020-08-27T09:53:59.4623955Z ##[error]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 sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at 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:189)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2020-08-27T09:53:59.4629678Z at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
2020-08-27T09:53:59.4630500Z at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
2020-08-27T09:53:59.4631592Z at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2020-08-27T09:53:59.4632594Z at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2020-08-27T09:53:59.4633338Z at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
2020-08-27T09:53:59.4634060Z at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
2020-08-27T09:53:59.4634908Z at java.lang.reflect.Method.invoke(Unknown Source)
2020-08-27T09:53:59.4635618Z at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2020-08-27T09:53:59.4636261Z at com.sun.proxy.$Proxy0.execute(Unknown Source)
2020-08-27T09:53:59.4636904Z at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2020-08-27T09:53:59.4637841Z at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2020-08-27T09:53:59.4641463Z ##[error]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 SonarScanner using the -X switch to enable full debug logging.
2020-08-27T09:53:59.4645118Z at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
2020-08-27T09:53:59.4645950Z at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
2020-08-27T09:53:59.4646703Z at org.sonarsource.scanner.cli.Main.main(Main.java:61)
2020-08-27T09:53:59.4647263Z ERROR:
2020-08-27T09:53:59.4647865Z ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
2020-08-27T09:53:59.5239693Z ##[error]The process ‘C:\Kodeeswaran\HWProject-Agent-Pool_work_tasks\SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1\1.15.0\sonar-scanner\bin\sonar-scanner.bat’ failed with exit code 1
2020-08-27T09:53:59.5329259Z ##[section]Finishing: Run Code Analysis

Please suggest some input.

Thanks,
Kodeeswaran S

Hi @mpaladin,

Thanks for guided me to achieve this.

I have resolved the above errors and able to create sonar report.

How to do unit testing can you provide some input.