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.
Related
trying to get the sonar scanner running from the command line at the moment with just msbuild.exe solution.sln /rebuild it's currently failing on the post-processing step and i can't seem to get beyond that
my java path is set in: C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe. I tried updating my path to a location that didn't have any spaces in it but no luck.
I also tried using dotnet sonar scanner and msbuild sonar scanner. both with the same result
These are the steps i'm executing:
dotnet-sonarscanner begin /k:"key" /d:sonar.host.url="https://my_company_sonarqube.com" /d:sonar.login="token" /d:sonar.verbose=true
MSBuild.exe solution.sln /t:Rebuild /p:Platform="Any CPU"
dotnet-sonarscanner end /d:sonar.login="token"
Everything seems to work fine until i get to the post-processing step:
Executing file C:\Users\userid\.dotnet\tools\.store\dotnet-sonarscanner\4.7.1\dotnet-sonarscanner\4.7.1\tools\netcoreapp2.1\any\sonar-scanner-4.1.0.1829\bin\sonar-scanner.bat
Args: -Dsonar.scanAllFiles=true -Dproject.settings=C:\Users\userid\Documents\project_path\.sonarqube\out\sonar-project.properties --embedded --debug <sensitive data removed>
Working directory: C:\Users\userid\Documents\project_path
Timeout (ms):-1
Process id: 38116
Error: Could not find or load main class
Process returned exit code 1
The SonarQube Scanner did not complete successfully
19:53:44.155 Post-processing failed. Exit code: 1
Using the following JDK
java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
ok so i'm not sure why i was getting the main class error. I re-ran everything using the sonarscanner batch script and then with a stripped down java call from the batch script and it seems like my problem was not having my ssl certificates for the sonarqube server.
Starting over and setting SONAR_SCANNER_OPTS seemed to do the trick.
set SONAR_SCANNER_OPTS = "-Djavax.net.ssl.trustStore="C:\path\to\trustStore"
We updated our SonarQube for Bamboo plugin to the latest version, 1.17.0, and now our SQ integration is broken. No reports are sent to our Sonar Qube server. I get these errors in the Bamboo build output:
This setting is not valid in the "end" phase in this version of the C# plugin: sonar.host.url
Failing task since return code of [C:\sonar\bin\MSBuild.SonarQube.Runner.exe end /d:sonar.host.url=http://[ip-address]:9000/sonar /d:sonar.login=*** /d:sonar.password=*** was 1 while expected 0
And:
SONAR4BAMBOO: was not able to find a SonarQube result URL
It seems like somewhere in the process it's passing sonar.host.url as an argument to executing the runner, but in the latest SonarQube for Bamboo plugin this is, for some reason, not allowed anymore? Has anyone updated SonarQube for Bamboo and come up against similar problems?
I'm the author of the plug-in. We've just released a bug fix version 1.7.1 which only sets the sonar.login parameter in the MSBuild end task, thus resolving this issue.
Best regards,
Michael
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.
I developed a custom rule for C# using Roslyn in VS2015, I deployed it under SonarQube 6.4 and activated it in my quality profile.
Then, I analyzed several .cs files under the same directory using sonar-scanner. But I got this error
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalArgumentException: Custom and 3rd party Roslyn analyzers are only by MSBuild 14. Either use MSBuild 14, or disable the custom/3rd party Roslyn analyzers in your quality profile.
at org.sonar.plugins.csharp.CSharpSensor.analyze(CSharpSensor.java:141)
at org.sonar.plugins.csharp.CSharpSensor.executeInternal(CSharpSensor.java:112)
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)
Once the rule deactivated, I can analyze my .cs files normally
I cannot use SonarQube Scanner for MSBuild, because it requires a whole project to analyze, but in my case, I can only have a directory of .cs files, this is why I need to use sonar-scanner
I saw here that a solution has been developed, but is it available currently?
Is there a solution I can analyze my files with my new rule under sonar-scanner?
Using the Scanner for MSBuild is a requirement for any analysis of .Net code with SonarQube. For reasons you've already made clear in fact:
C# rules (e.g. from SonarC#) rely on the Roslyn framework
Roslyn is a Microsoft framework, which kicks in during compilation of the code
Roslyn-based analyzers therefore require msbuild execution
SonarQube analysis of .Net code therefore requires to use the Scanner for MSBuild (which integrates with msbuild)
For all above reasons, it is not possible to analyze individual .cs files with any other scanner.
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!