SonarQube MSBuild Runner defaults to h2 Database - c#

I am using Win Server 2012, Developer Command Prompt for VS2013, SonarQube v5.1.2, SonarQube Scanner for MSBuild 1.1.
I have my Sonar instance running off this same server, but connected to an Oracle database. Using the default sonar runner, i can analyze projects properly and see them appear in the dashboard using this method. That cannot be said for using the recommended MSBuild.SonarQube.Runner.exe approach.
I have tried with the csharp and vbnet examples, as well as our actual code. Oddly, i want to say each of these have worked at least once, but fail to do so now. Today, I tried using the vbnet example project for the first time and discovered and it worked as intended when using the MSBuild runner. I deleted the project from the dashboard, and ran it again. At this point i do not remember it it worked or not, but the third time for sure it stopped working and began producing the error below (wherein it tries to connect to the default h2 database instead of the oracle one that SonarQube is connected to).
I tried deleting the examples folder, extracting it again, giving it a slightly different name, and running the Sonar on it giving THOSE a different name/key/version, but now it is consistently giving me the db error.
Any idea what could be going on here, and why it would go from working to not, without me making any changes to the runner, msbuild, or the code?
Running the begin step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe b
egin /v:vbnet1 /k:vbnet1 /n:vbnet1
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
MSBuild SonarQube Runner Pre-processor 1.0.2.0
17:40:49.625 Loading analysis properties from c:\sonarqube\bin\SonarQube.Analys
is.xml
17:40:49.656 Updating build integration targets...
17:40:49.656 Fetching analysis configuration settings...
17:40:50.813 Generating rulesets...
Pre-processing succeeded.
MSBuild ran, but nothing worthwhile to post from it..
Running the end step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe e
nd
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Post-processing started.
MSBuild SonarQube Runner Post-processor 1.0.2.0
WARNING: File is not under the project directory and cannot currently be analyse
d by SonarQube. File: C:\Users\ts3conusr\AppData\Local\Temp\.NETFramework,Versio
n=v4.5.AssemblyAttributes.vb, project: c:\sonar-examples-master\projects\languag
es\vbnet\ConsoleApplication1\ConsoleApplication1.vbproj
The SONAR_RUNNER_HOME environment variable is not required and will be ignored.
SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024
m
Calling the sonar-runner...
c:\sonar-examples-master\projects\languages\vbnet\.sonarqube\bin\sonar-runner\bi
n\..
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (32-bit)
Windows Server 2008 R2 6.1 x86
SONAR_RUNNER_OPTS=-Xmx1024m
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: c:\sonar-examples-master\projects\languages\vbn
et\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: c:\sonar-examples-master\projects\languages\vb
net\.sonarqube\out\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: c:\sonar-examples-master\projects\languages\vbnet\.sonarqu
be\out\.sonar
INFO: SonarQube Server 5.1.2
17:41:04.563 INFO - Load global repositories
17:41:04.751 INFO - Load global repositories (done) | time=188ms
17:41:04.751 INFO - Server id: 20160120154951
17:41:04.751 INFO - User cache: C:\Users\ts3conusr\.sonar\cache
17:41:04.766 INFO - Install plugins
17:41:04.860 INFO - Install JDBC driver
17:41:04.860 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.047s
Final Memory: 3M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
Of note: I feel that it is worth mentioning that the vbnet report didn't actually have any content in it, but did at least properly get generated in the Sonar dashboard. I have tried running the commands against both that and the csharp example with now neither of them being added to the dashboard.

In the MSBuild.SonarQube.Runner install folder, there is a SonarQube.Analysis.xml. Do you have the correct server details on the below line in there?
<Property Name="sonar.host.url">http://{host}:{port}/{optionalPath}</Property>
This property value should point to your Sonar server.

Couple other things to try. Do you see tables being populated with analysis data in your oracle database? When was the last time it got any record?
Also, are you seeing below warning on your SonarQube application pages (say default dashboard)? If yes, then oracle configuration is not being picked up.

So i upgraded to the latest SonarQube version (5.3) and upgraded a few of the extensions while i was at it and preliminary testing is showing positive results. Ill try it a few more times but im closing the question for now. Thank you all that helped!

Related

Cannot send build results to SonarQube server

I'm working on a POC and I'm able to create a project and send the build results to SonarQube localhost server without any errors.
But when I build the same project and send the the results to production server, build will succeed but the results on the server is empty.
In the server, I'm getting the following warning.
SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
I found that, its not creating the output-cs folder. when i run these commands in local its creating those files and folders but for production server its not.
Path to output-cs
C:\Users\Administrator\Desktop\my-project.sonarqube\out\0
Code I ran for localhost:
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe begin
/k:"my-test-project" /d:sonar.verbose=true /d:sonar.host.url="http://localhost:9000"
/d:sonar.login="project-token"
MsBuild.exe /t:Rebuild
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe end
/d:sonar.login="project-token"
Code I ran for Production Sever:
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe begin
/k:"my-test-project" /d:sonar.verbose=true /d:sonar.host.url="http://prod-server-url"
/d:sonar.login="sonarqube_project_token"
MSBuild.exe /t:Rebuild
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe end
/d:sonar.login="sonarqube_project_token"
Difference between those two codes is only the SonarQube project name and token only.
I went through the build stack trace and found some warnings.
WARN: No coverage report can be found with
sonar.coverage.jacoco.xmlReportPaths='build/reports/jacoco/test/jacocoTestReport.xml'.
Using default locations:
target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
Doubt:
Do we need to specifically mention some additional parameters when building for server compared to localhost?
Note: This is c# application.

Getting error while running SonarScannerMSBuild on Xamarin projects

1) When I Try to use Rebuild option
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/MSBuild.SonarQube.Runner.exe /t:Rebuild
WARNING: ------------------------------------------------------------------------
This executable is deprecated and may be removed in next major version of the SonarScanner for MSBuild. Please use 'SonarScanner.MSBuild.exe' instead.
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Pre-processing started.
Preparing working directories...
05:23:39.463 05:23:39.454 Unrecognized command line argument: /t:Rebuild
05:23:39.464 05:23:39.462 A required argument is missing: /key:[SonarQube project key]
05:23:39.464 Expecting at least the following command line argument:
SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
SonarQube project name
SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
05:23:39.464 Pre-processing failed. Exit code: 1
2) I get some other error with authentication problems. Any work around this.
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarScanner.MSBuild.exe begin /k:"Xamarin" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token1"
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
05:18:52.798 Updating build integration targets...
05:18:52.833 Fetching analysis configuration settings...
05:18:52.94 Failed to request and parse 'http://localhost:9000/api/settings/values?component=Xamarin': The remote server returned an error: (401) .
05:18:52.94 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
05:18:52.941 Pre-processing failed. Exit code: 1

ERROR: XXX.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

We've upgraded our SonarQube instance to 6.7 version and since then we see a project failing with below error during SonarQube analysis from VSTS build.
ERROR: Error during SonarQube Scanner execution ERROR: File
src/Platform/DeviceProvisioning/Business.Contracts/Models/DeviceDetailsForReplication.cs
can't be indexed twice. Please check that inclusion/exclusion patterns
produce disjoint sets for main and test files ERROR: ERROR: Re-run
SonarQube Scanner using the -X switch to enable full debug logging.
The SonarQube Scanner did not complete successfully
However the same project gets analyzed without any issue in our SonarQube 6.1 instance. To check if the issue is with test file inclusion settings, i tried creating a new SonarQube project with no explicit setting for inclusion\exclusion but i still get the same error on a new project.
Can someone let me know how we can fix the issue.

Jenkins Error SonarQube Scanner execution

After reviewing lots of posts and blogs I still can´t figure this out.
This my current stack
Sonar: 6.3.0.19869
Sonar Code Analyzer for C#: 5.10.1 (build 1411)
Jenkins: 2.46.1
Jenkins sonarqube scanner: 2.6.1
TFS branches:
- Dev
- Main
Sonarqube projects (deactivated rules S104, S105)
- Dev
- Main
When I run DEV Branch Jenkins Job, the upload to sonar DEV project is successful
When I run DEV Branch Jenkins Job, the upload to sonar Main project is successful
When I run Main Branch Jenkins Job, the upload to sonar Main project FAILS
DEV - DEV = OK
DEV - MAIN = OK
MAIN - MAIN = ERROR
Both file sets generated by sonarQube scanner are about 100Mb (Dev 111MB / Main 106MB)
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Start pointer [line=4541, lineOffset=49] should be before end pointer [line=4541, lineOffset=49]
at org.sonar.api.internal.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(DefaultInputFile.java:265)
at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(DefaultInputFile.java:203)
at org.sonarsource.dotnet.shared.plugins.SensorContextUtils.toTextRange(SensorContextUtils.java:41)
at org.sonarsource.dotnet.shared.plugins.protobuf.SymbolRefsImporter.consumeFor(SymbolRefsImporter.java:47)
at org.sonarsource.dotnet.shared.plugins.protobuf.SymbolRefsImporter.consumeFor(SymbolRefsImporter.java:33)
at org.sonarsource.dotnet.shared.plugins.protobuf.ProtobufImporter.consume(ProtobufImporter.java:50)
at org.sonarsource.dotnet.shared.plugins.protobuf.RawProtobufImporter.accept(RawProtobufImporter.java:44)
at org.sonarsource.dotnet.shared.plugins.AbstractSensor.parseProtobuf(AbstractSensor.java:90)
at org.sonarsource.dotnet.shared.plugins.AbstractSensor.importResults(AbstractSensor.java:83)
at org.sonar.plugins.csharp.CSharpSensor.executeInternal(CSharpSensor.java:119)
at org.sonar.plugins.csharp.CSharpSensor.execute(CSharpSensor.java:79)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:57)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:49)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:74)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:175)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:262)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:257)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:247)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:47)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:86)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:143)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:128)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:118)
at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:117)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:233)
at org.sonarsource.scanner.api.EmbeddedScanner.runAnalysis(EmbeddedScanner.java:151)
at org.sonarsource.scanner.cli.Main.runAnalysis(Main.java:123)
at org.sonarsource.scanner.cli.Main.execute(Main.java:77)
at org.sonarsource.scanner.cli.Main.main(Main.java:61)
What I can think of is that is something wrong with the MAIN code base, but can't figure it out
Any ideas?
We recently received a bug report with the same error: Tuple literals make the analysis fail, I suppose it could be caused by other C# 7 constructs as well. Unfortunately we don't have a fix or workaround yet (except not using some C# 7 features for the time being).
I cannot promise a fix for the next version of SonarC# because we did not investigated the problem yet, but we will do our best to resolve the problem as soon as possible.

SonarQube can't complete the post-build step

I got a Jenkins Server set up on Windows 2012 R2. These are my build settings:
Underneath you see the error. It should be said that the pre-build step runs successfully:
[Test CSharp Build Job] $ ...\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\MSBuild.SonarQube.Runner.exe end
SonarQube Scanner for MSBuild 2.0
Default properties file was found at ...\Documents\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\SonarQube.Analysis.xml
Loading analysis properties from ...\Documents\Jenkins\.jenkins\tools\hudson.plugins.sonar.MsBuildSQRunnerInstallation\MSBuild_2.0\SonarQube.Analysis.xml
Post-processing started.
SonarQube Scanner for MSBuild End Step 1.1
No ProjectInfo.xml files were found. Possible causes:
1. The project has not been built - the end step was called right after the begin step, without a build step in between
2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 12.0 upwards are supported
3. The build step has been launched from a different working folder
Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
11:18:18.015 Creating a summary markdown file...
Post-processing failed. Exit code: 1
ERROR: Execution of SonarQube Scanner for MSBuild failed (exit code 1)
So in my Jenkins Configuration I have this:
Am I missing something to make this work?
Okay I figured it out
I forgot to add a /t:rebuild in between building with MSBuild and running the End Analysis command.

Categories

Resources