SonarQube azure extension doesn't publish code coverage result to SonarQube server

Hi everyone,

I’ve tried to automate my project with Azure pipeline. I’m using the SonarQube extension to analyze my solution. The build pipeline works perfectly, the .coverage file is generated on the build agent server after the test task is complete. The result of analysis is published to SonarQube server except for the code coverage.

This is what I have:

  • A .NET project.
  • A SonarQube server.
  • A build agent server with SonarScanner for MSBuild 4.6.2.2108

I’ve installed the SonarQube extension and used 3 tasks:

  • Prepare analysis on SonarQube
  • Run Code analysis
  • Publish quality gate result

Could you guys help me to figure out why?

Hi,

Do you have the csharp plugin correctly installed on your SonarQube instance ?

Might it be possible for you to share the Run Code analysis code ?

Thanks.

Hi Mickael,

Thank you for your response. I’m not sure about the C# Plugin on SonarQube instance. Let me check with the team because I don’t have privileges.

And Here is the log of Run Code Analysis.

[command]C:\agent_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.6.3\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe end

SonarScanner for MSBuild 4.6.2

Using the .NET Framework version of the Scanner for MSBuild

Post-processing started.

02:52:27.975 Fetching code coverage report information from TFS…

02:52:27.975 Attempting to locate a test results (.trx) file…

02:52:28.334 Looking for TRX files in: C:\agent_work\2\TestResults, C:\agent_work\2\s\TestResults

02:52:28.334 The following test results files were found: C:\agent_work\2\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30.trx

02:52:28.709 The following code coverage attachments were found from the trx files: C:\agent_work\2\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30\In\BUILD-AGENT\dusbuild_BUILD-AGENT 2019-06-17 02_51_24.coverage

WARNING: File ‘C:\agent_work\2\s\DUS.StylingAndPrototypes\Properties\PublishProfiles\FolderProfile.pubxml’ does not exist.

Calling the SonarQube Scanner…

INFO: Scanner configuration file: C:\agent_work_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.6.3\classic-sonar-scanner-msbuild\sonar-scanner-3.3.0.1492\bin…\conf\sonar-scanner.properties

INFO: Project root configuration file: C:\agent_work\2.sonarqube\out\sonar-project.properties

INFO: SonarQube Scanner 3.3.0.1492

INFO: Java 12.0.1 Oracle Corporation (64-bit)

INFO: Windows Server 2019 10.0 amd64

INFO: User cache: C:\Users\dusbuild.sonar\cache

INFO: SonarQube server 7.6.0

INFO: Default locale: “en_US”, source code encoding: “windows-1252” (analysis is platform dependent)

INFO: Load global settings

WARNING: WARNING: An illegal reflective access operation has occurred

WARNING: WARNING: Illegal reflective access by com.google.protobuf.UnsafeUtil (file:/C:/Users/dusbuild/.sonar/cache/6d01b89272ed2dc28151240b26b39a69/sonar-scanner-engine-shaded-developer-7.6-all.jar) to field java.nio.Buffer.address

WARNING: WARNING: Please consider reporting this to the maintainers of com.google.protobuf.UnsafeUtil

WARNING: WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: WARNING: All illegal access operations will be denied in a future release

INFO: Load global settings (done) | time=986ms

INFO: Server id: F4B506BB-AWmWk2NgJ9QhC9gg9JC8

INFO: User cache: C:\Users\dusbuild.sonar\cache

INFO: Load/download plugins

INFO: Load plugins index

INFO: Load plugins index (done) | time=109ms

INFO: Load/download plugins (done) | time=2328ms

INFO: Loaded core extensions: branch-scanner

INFO: Process project properties

INFO: Execute project builders

INFO: Execute project builders (done) | time=94ms

WARN: Failed to set working directory hidden: C:\agent_work\2.sonarqube\out.sonar

INFO: Project key: DPSDUS

INFO: Base dir: C:\agent_work\2\s

INFO: Working dir: C:\agent_work\2.sonarqube\out.sonar

WARN: Failed to set working directory hidden: C:\agent_work\2.sonarqube\out.sonar\mod0

INFO: Load project settings

INFO: Load project settings (done) | time=63ms

INFO: Load project branches

INFO: Load project branches (done) | time=79ms

INFO: Load project pull requests

INFO: Load project pull requests (done) | time=32ms

INFO: Load branch configuration

INFO: Load branch configuration (done) | time=15ms

INFO: Load project repositories

INFO: Load project repositories (done) | time=219ms

INFO: Load quality profiles

INFO: Load quality profiles (done) | time=125ms

INFO: Load active rules

INFO: Load active rules (done) | time=2080ms

INFO: Load metrics repository

INFO: Load metrics repository (done) | time=109ms

WARN: Property ‘sonar.abap.file.suffixes’ is not declared as multi-values/property set but was read using ‘getStringArray’ method. The SonarQube plugin declaring this property should be updated.

INFO: Indexing files…

INFO: Project configuration:

INFO: Indexing files of module ‘DUS.StylingAndPrototypes’

INFO: Base dir: C:\agent_work\2\s\DUS.StylingAndPrototypes

INFO: Source paths: App_Start/BundleConfig.cs, App_Start/FilterConfig.cs, App_Sta…

INFO: Indexing files of module ‘DPSDUS’

INFO: Base dir: C:\agent_work\2\s

INFO: 85 files indexed

INFO: Quality profile for cs: Sonar way

INFO: Quality profile for css: Sonar way

INFO: Quality profile for js: Sonar way

INFO: Quality profile for ts: Sonar way

INFO: Quality profile for web: Sonar way

INFO: ------------- Run sensors on module DUS.StylingAndPrototypes

INFO: Sensor SonarCSS Metrics [cssfamily]

INFO: Sensor SonarCSS Metrics [cssfamily] (done) | time=2312ms

INFO: Sensor SonarCSS Rules [cssfamily]

INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=36550ms

INFO: Sensor C# Properties [csharp]

INFO: Sensor C# Properties [csharp] (done) | time=0ms

INFO: Sensor JavaXmlSensor [java]

INFO: Sensor JavaXmlSensor [java] (done) | time=78ms

INFO: Sensor HTML [web]

INFO: Sensor HTML [web] (done) | time=219ms

INFO: Sensor SonarTS [typescript]

INFO: No tsconfig.json file found for 1 file(s) (Run in debug mode to see all of them). They will be analyzed with a default configuration.

INFO: Analyzing 1 typescript file(s) with the following configuration file DEFAULT_TSCONFIG

INFO: 1 files analyzed out of 1

INFO: Analyzing 6 typescript file(s) with the following configuration file C:\agent_work\2\s\DUS.StylingAndPrototypes\Assets\tsconfig.json

INFO: 6 files analyzed out of 6

INFO: Sensor SonarTS [typescript] (done) | time=13873ms

INFO: Sensor JaCoCo XML Report Importer [jacoco]

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=15ms

INFO: Sensor SonarJS [javascript]

INFO: 16 source files to be analyzed

INFO: 1/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/bootstrap.bundle.js

INFO: 2/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/bootstrap.js

INFO: 6/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.js

INFO: 6/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.js

INFO: 6/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.js

INFO: 11/16 files analyzed, current file: DUS.StylingAndPrototypes/Scripts/modernizr-2.8.3.js

INFO: 16/16 source files have been analyzed

INFO: Sensor SonarJS [javascript] (done) | time=76792ms

INFO: Sensor ESLint-based SonarJS [javascript]

INFO: Using default Node.js executable: ‘node’.

INFO: 16 source files to be analyzed

INFO: Sensor ESLint-based SonarJS [javascript] (done) | time=33040ms

INFO: ------------- Run sensors on module DPSDUS

INFO: Sensor JavaXmlSensor [java]

INFO: Sensor JavaXmlSensor [java] (done) | time=0ms

INFO: Sensor JaCoCo XML Report Importer [jacoco]

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms

INFO: Sensor C# [csharp]

INFO: Importing results from 6 proto files in ‘C:\agent_work\2.sonarqube\out\0\output-cs’

INFO: 16/16 source files have been analyzed

INFO: Importing 1 Roslyn report

INFO: Sensor C# [csharp] (done) | time=656ms

INFO: Sensor C# Tests Coverage Report Import [csharp]

INFO: Parsing the Visual Studio coverage XML report C:\agent_work\2\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30\In\BUILD-AGENT\dusbuild_BUILD-AGENT 2019-06-17 02_51_24.coveragexml

INFO: Adding this code coverage report to the cache for later reuse: C:\agent_work\2\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30\In\BUILD-AGENT\dusbuild_BUILD-AGENT 2019-06-17 02_51_24.coveragexml

INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=6129ms

INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]

WARN: Starting with SonarQube 6.2 separation between Unit Tests and Integration Tests Coverage reports is deprecated. Please move all reports specified from *.it.reportPaths into *.reportPaths.

INFO: Parsing the Visual Studio coverage XML report C:\agent_work\2.\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30\In\BUILD-AGENT\dusbuild_BUILD-AGENT 2019-06-17 02_51_24.coveragexml

INFO: Adding this code coverage report to the cache for later reuse: C:\agent_work\2.\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30\In\BUILD-AGENT\dusbuild_BUILD-AGENT 2019-06-17 02_51_24.coveragexml

INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=8469ms

INFO: Sensor C# Unit Test Results Import [csharp]

INFO: Parsing the Visual Studio Test Results file C:\agent_work\2\s\TestResults\dusbuild_BUILD-AGENT_2019-06-17_02_51_30.trx

INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=94ms

INFO: Sensor Zero Coverage Sensor

INFO: Sensor Zero Coverage Sensor (done) | time=344ms

INFO: Sensor JavaSecuritySensor [security]

INFO: Reading UCFGs from: C:\agent_work\2.sonarqube\out.sonar\ucfg2\java

INFO: 02:56:14.9991855 Building Type propagation graph

INFO: 02:56:14.9991855 Running Tarjan on 0 nodes

INFO: 02:56:14.9991855 Tarjan found 0 components

INFO: 02:56:14.9991855 Variable type analysis: done

INFO: UCFGs: 0, excluded: 0, source entrypoints: 0

INFO: No UCFGs have been included for analysis.

INFO: Sensor JavaSecuritySensor [security] (done) | time=15ms

INFO: Sensor CSharpSecuritySensor [security]

INFO: Reading UCFGs from: C:\agent_work\2.sonarqube\out\ucfg_cs2

INFO: 02:56:15.1241937 Building Type propagation graph

INFO: 02:56:15.1554288 Running Tarjan on 28 nodes

INFO: 02:56:15.1554288 Tarjan found 28 components

INFO: 02:56:15.1554288 Variable type analysis: done

INFO: UCFGs: 7, excluded: 4, source entrypoints: 3

INFO: Analyzing 7 ucfgs to detect vulnerabilities.

INFO: All rules entrypoints : 0 Retained UCFGs : 0

INFO: rule: S3649, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S3649 done

INFO: rule: S2076, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S2076 done

INFO: rule: S2091, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S2091 done

INFO: rule: S2078, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S2078 done

INFO: rule: S2631, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S2631 done

INFO: rule: S2083, entrypoints: 0

INFO: Visited 0 ucfgs in 0 ms, 0 steps

INFO: rule: S2083 done

INFO: Sensor CSharpSecuritySensor [security] (done) | time=219ms

INFO: ------------- Run sensors on project

INFO: 5 files had no CPD blocks

INFO: Calculating CPD for 30 files

WARN: Too many duplication references on file DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.intellisense.js for block at line 2. Keep only the first 100 references.

WARN: Too many duplication references on file DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.intellisense.js for block at line 2. Keep only the first 100 references.

WARN: Too many duplication references on file DUS.StylingAndPrototypes/Scripts/jquery-3.3.1.intellisense.js for block at line 2. Keep only the first 100 references.

INFO: CPD calculation finished

INFO: Analysis report generated in 2131ms, dir size=4 MB

INFO: Analysis report compressed in 500ms, zip size=1 MB

INFO: Analysis report uploaded in 1810ms

INFO: ANALYSIS SUCCESSFUL, you can browse http://###

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://###

INFO: Analysis total time: 3:51.185 s

INFO: ------------------------------------------------------------------------

INFO: EXECUTION SUCCESS

INFO: ------------------------------------------------------------------------

INFO: Total time: 3:59.446s

INFO: Final Memory: 29M/262M

INFO: ------------------------------------------------------------------------

The SonarQube Scanner has finished

02:56:30.556 Post-processing succeeded.

Thank you !

As far i can see, coverage is well discovered and parsed by the engine.

Is that your default branch that your are analyzing ? Or another one or a Pull Request ?

Hi Mickael,

This is the master branch and currenly I’ve only worked on this one. I haven’t activated the pull request yet.

So, any settings required which could cause this problem?