Running Sonarqube in jenkins gives me the following error and is not uploading the results

scanner
dotnet
csharp
sonarqube

(r.kuma) #1

I have built our c-sharp solution, and we use dotcover for code coverage

the following is the output generated.

C:\Client\DEV\DEV_3.3.0\TEST> SonarScanner.MSBuild.exe begin /k:"Client-3.3.0" /n:"Client-3.3.0" /v:"2.0" /d:sonar.cs.dotcover.reportsPaths="C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport.html"

SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonarqube\msbuild\SonarQube.Analysis.xml`
Loading analysis properties from C:\sonarqube\msbuild\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
15:19:13.733  Updating build integration targets...
15:19:13.766  Fetching analysis configuration settings...
15:19:14.075  Provisioning analyzer assemblies for cs...
15:19:14.077  Installing required Roslyn analyzers...
15:19:14.203  Pre-processing succeeded.


C:\Client\DEV\DEV_3.3.0\TEST>
C:\Client\DEV\DEV_3.3.0\TEST>msbuild ..\source\Clientside.sln

.....
.....
.....
300 Warning(s)
0 Error(s)
Time Elapsed 00:03:06.10

Now, as explained in the website sonarqube-dotcover, i ran the dotcover

C:\Client\DEV\DEV_3.3.0\TEST> dotcover analyse /ReportType=HTML /Output="C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport.html" /TargetExecutable="C:\Client\DEV\DEV_3.3.0\3rdparty\NUnit.Console-3.9.0\nunit3-console.exe" /TargetArguments="C:\Client\DEV\DEV_3.3.0\TEST\ClientTest.nunit"

And this is the output after i ran the sonarscanner end operation.

C:\Client\DEV\DEV_3.3.0\TEST>SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonarqube\msbuild\SonarQube.Analysis.xml
Loading analysis properties from C:\sonarqube\msbuild\SonarQube.Analysis.xml
Post-processing started.
.....
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\sonarqube\msbuild\sonar-scanner-3.2.0.1227\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\Client\DEV\DEV_3.3.0\TEST\.sonarqube\out\sonar-project.properties
............
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=4ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=3ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.

........
......

INFO: Source encoding: windows-1252, default locale: en_US
INFO: Index files
INFO: 5 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Importing analysis results from C:\Client\DEV\DEV_3.3.0\TEST\null\output-cs
INFO: Sensor C# [csharp] (done) | time=6ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=1ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Aggregating the HTML reports from C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\1.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\10.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\100.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\101.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\102.html
INFO: Parsing the dotCover report C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\103.html
   ......

    .....

INFO: Adding this code coverage report to the cache for later reuse: C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport.html
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
**INFO: Total time: 22.134s**

** INFO: Final Memory: 11M/44M**
** INFO: ------------------------------------------------------------------------**
** ERROR: Error during SonarQube Scanner execution**
** ERROR: Line 129 is out of range in the file source/PipeClient.cs (lines: 128)**
** ERROR:**
** The SonarQube Scanner did not complete successfully**
** 15:10:44.674 Creating a summary markdown file…**
** 15:10:44.685 Post-processing failed. Exit code: 1**

C:\Client\DEV\DEV_3.3.0\TEST>

Contents of the ClientTest.nunit file contains paths to various dlls’

And if I run the same commands through jenkins, i get this error :

INFO: Source encoding: UTF-8, default locale: en_US
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 14.850s
INFO: Final Memory: 7M/85M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: Unable to load component class org.sonar.scanner.phases.AbstractPhaseExecutor
ERROR: Caused by: Unable to load component class org.sonar.scanner.issue.ignore.scanner.IssueExclusionsLoader
ERROR: Caused by: Dangling meta character '*' near index 0
**/src/main/java/com/dell/customtools/integration/td/proxy/**
^
ERROR: 
The SonarQube Scanner did not complete successfully
21:11:25.365  Creating a summary markdown file...
21:11:25.369  Post-processing failed. Exit code: 1
WARN: Unable to locate 'report-task.txt' in the workspace. Did the SonarScanner succedeed?
ERROR: Execution of SonarScanner for MSBuild failed (exit code 1)
Archiving artifacts
Extended Email Publisher is currently disabled in project settings
Finished: FAILURE

Very rarely i could see, sonarqube compiles and gives results, but if i check on the coverage it says 0.0%

FYI, i am using the following tools

  • dotcover Version: 2018.3.1

  • sonarqube - LTS - 6.7.x

  • MSBuild version (as in the output - 4.4.2)

P.S the problem is, the dotcover , after the analysis, able to generate the .html file, and i can see the results in it, but i am not able to see that in sonarqube. either it throws the above erros or it shoes 0.0% have given the additional arguments also :
(/d:sonar.cs.dotcover.reportsPaths="C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport.html)

I have another question, as you can see in the above printed logs, sonarqube creates a separate coverage report and adds all the code in html format and tries to compress them.
Not sure what is this operation.

Pleae help, as i am stuck in this for a week. its very important.


(Amaury Levé) #2

Hi @r.kumar,

Could you try to re-run another analysis but skipping the code coverage? Could you confirm that doing so the analysis works properly?

If so, there might be something we don’t parse properly in the html of the code coverage. Could you share the one failing? It seems to be C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\103.html.

Cheers,
Amaury


(r.kuma) #4

Thanks for the reply.
im trying ! will update in few mins

update:
ya, it works completely fine without dotcover code coverage in jenkins.
i think as you said, ts the html parsing where it fails.

attaching some logs.
.
INFO: CPD calculation finished
INFO: Analysis report generated in 15824ms, dir size=20 MB
INFO: Analysis reports compressed in 11335ms, zip size=7 MB
INFO: Analysis report uploaded in 617ms
INFO: ANALYSIS SUCCESSFUL, you can browse http:// . ./dashboard/index/client-2.0
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http:// . ./api/ce/task?id=AWg9uNJA3oHAopXOffA3
INFO: Task total time: 1:52.034 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 2:04.021s
INFO: Final Memory: 12M/595M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
10:22:40.398 Creating a summary markdown file…
10:22:40.426 Analysis results: http:// . ./dashboard/index/client-2.0
10:22:40.427 Post-processing succeeded.
Archiving artifacts
Extended Email Publisher is currently disabled in project settings
Finished: SUCCESS

can you please suggest some workaround or fix as it is very important, the dotcover results in sonarqube triggered in jenkins.

Thanks.


(Amaury Levé) #5

Could you share the file C:\Client\DEV\DEV_3.3.0\TEST\CoverageReport\src\103.html which seems to be the last one parsed before the failure?


(r.kuma) #6

actually it is not open source code. it may go against our company policy, so i cannot share. sorry, :cry: these html files , as you know , are the csharp files of our project. there were around 400-500 files generated, i just shared a snapshot of it.

any other way ? thanks.


(r.kuma) #8

But all the *.html files that are inside the generated ClientCoverageReport folder, when i run the command SonarScanner.MSBuild.exe end, has the following structure.

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>C:\Client\DEV\DEV_3.3.0\source\clientSpace\Handler.cs</title>
    <script type="text/javascript" src="../js/dotcover.sourceview.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/dotcover.report.css" />
  </head>
  <body>
    <pre id="content" class="source-code">
using namespace1;
using namespace2;
namespace ns1 {
public class : interface1 {
....
....
....
}

}

</pre>
<script type="text/javascript">
  highlightRanges([[16,9,16,92,0],[21,63,21,67,0],[21,68,21,72,0],[24,41,24,45,0],[24,46,24,50,0],[27,61,27,65,0],[27,66,27,70,0],[32,9,32,10,0],[34,13,34,14,0],[36,17,42,19,0],[44,17,44,73,0],[45,21,45,28,0],[46,17,46,66,0],[47,21,47,28,0],[49,17,49,61,0],[50,17,50,18,0],[51,21,51,47,0],[52,21,52,28,0],[54,17,54,232,0],[55,13,55,14,0],[56,13,56,33,0],[57,13,57,14,0],[58,17,58,88,0],[59,13,59,14,0],[60,9,60,10,0],[64,9,64,10,0],[66,13,66,14,0],[67,17,67,79,0],[68,21,68,28,0],[70,17,70,50,0],[71,21,71,77,0],[73,17,73,124,0],[74,17,74,120,0],[75,17,75,149,0],[76,17,76,97,0],[78,17,78,123,0],[80,17,80,91,0],[81,13,81,14,0],[82,13,82,33,0],[83,13,83,14,0],[84,17,84,185,0],[85,13,85,14,0],[87,9,87,10,0],[92,9,92,10,0],[94,13,94,14,0],[96,17,102,19,0],[104,17,104,64,0],[105,21,105,50,0],[107,21,107,46,0],[108,13,108,14,0],[109,13,109,33,0],[110,13,110,14,0],[111,17,111,191,0],[112,13,112,14,0],[113,9,113,10,0],[118,9,118,10,0],[120,13,120,14,0],[122,17,128,19,0],[130,17,130,79,0],[131,21,131,28,0],[133,17,133,61,0],[134,17,134,160,0],[135,13,135,14,0],[136,13,136,33,0],[137,13,137,14,0],[138,17,138,183,0],[139,13,139,14,0],[140,9,140,10,0],[145,9,145,10,0],[146,13,146,75,0],[147,17,147,24,0],[149,13,166,15,0],[167,13,167,122,0],[168,13,168,58,0],[169,13,169,155,0],[170,9,170,10,0],[173,9,173,10,0],[174,13,174,75,0],[175,17,175,24,0],[177,13,194,15,0],[195,13,195,86,0],[196,13,196,87,0],[197,13,197,58,0],[199,13,199,155,0],[200,9,200,10,0],[206,9,206,10,0],[208,13,208,14,0],[209,17,209,54,0],[210,17,210,79,0],[211,21,211,28,0],[213,17,213,50,0],[214,21,214,77,0],[216,17,216,231,0],[218,17,218,94,0],[219,17,219,80,0],[220,17,220,107,0],[221,17,221,192,0],[223,17,223,64,0],[224,17,224,52,0],[225,21,225,162,0],[227,17,227,53,0],[230,17,230,53,0],[231,13,231,14,0],[232,13,232,33,0],[233,13,233,14,0],[234,17,234,153,0],[235,17,235,65,0],[236,17,236,94,0],[237,13,237,14,0],[238,9,238,10,0]]);
</script>
  </body>
</html>

Any help ? thanks.


(r.kuma) #9

Fortunately, when i tried running it now, it works,

but still there is a problem

but the coverage shows 0.0%

when i click on it, it unfortuantely shows only the .js , .css files

it doesnt have any c-sharp files.

but the ClientCoverageReport.html file, that is generated via dotcover, it has c# files and the coverage percentage also, but it is not getting integrated into sonarqube, as you can see it is giving 0.0%

please help. Thanks.