Scan results not being shown in SonarQube site

  • what are you trying to achieve
  • what have you tried so far to achieve this

Version:
SonarScanner for MSBuild 4.6
Using the .NET Core version of the Scanner for MSBuild

I am trying to get the scan results posted to the our instance of the SQ web site.

I’ve googled for my issue but haven’t found anything that helped me solve.

From the log, I can see this:

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://localhost:9000/api/ce/task?id=AXMuTFFcyx0pbtLeTidE
INFO: Task total time: 14.655 s

When I go to /dashboard/index/TNCIT:WebBackend, I see a page with the current build number but none of the items reported in the scan are listed in this web site. Everything shows as 0 (A), 0.0% or just 0.

Hi @EricBrian

Could you please clarify what are the steps that you are taking (what are the commands that you are running) and what exactly your problem is?

Also:

  • what is the version of SQ?
  • please give us the verbose output of the END step (please run SonarScanner.MSBuild.exe begin /k:"MyProject" /d:sonar.verbose=true as the BEGIN step, and please attach the output of END step)
  • are you running all commands from the same folder?

Thanks!

Hello.

Do I just paste everything right here? Is there anything in there that might be a security concern if I don’t remove?

Thanks
Eric

Ok, I hope there is nothing sensitive here… here goes:

The Jenkins Stage:

stage('SonarQube analysis') {
    environment {
        SQ_TOKEN = credentials('HubJenkinsSonarQubeUser2')
    }
    steps {
        withSonarQubeEnv('HubSonarQube') {
            sh "dotnet '/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll' begin /k:${SONARQUBEPROJECTKEY} /n:\"WebBackend\" /v:${env.BUILD_NUMBER} /d:sonar.login=\"${SQ_TOKEN}\" /d:sonar.links.homepage=\"http://<removed>:9000/dashboard?id=TNCIT%3AWebBackend\" /d:sonar.exclusions=\"**/TestResults/TestResult.xml\""
            sh "dotnet build 'src/WebBackend.sln'"
            sh "dotnet '/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll' end /d:sonar.login=\"${SQ_TOKEN}\""
        }
    }
}

Here is the END step:

+ dotnet /usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll end /d:sonar.login=****
SonarScanner for MSBuild 4.6
Using the .NET Core version of the Scanner for MSBuild
Post-processing started.
WARNING: File '/var/lib/jenkins/.nuget/packages/microsoft.aspnetcore.azurekeyvault.hostingstartup/2.0.4/contentFiles/cs/netstandard2.0/_AssembyInfo.KeyVaultHostingStartup.cs' is not located under the root directory '/var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src' and will not be analyzed.
WARNING: File '/var/lib/jenkins/.nuget/packages/microsoft.net.test.sdk/16.3.0/build/netcoreapp1.0/Microsoft.NET.Test.Sdk.Program.cs' is not located under the root directory '/var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src' and will not be analyzed.
WARNING: File '/var/lib/jenkins/.nuget/packages/xunit.runner.visualstudio/2.4.1/build/netcoreapp1.0/xunit.runner.visualstudio.dotnetcore.testadapter.dll' is not located under the root directory '/var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src' and will not be analyzed.
WARNING: File '/var/lib/jenkins/.nuget/packages/xunit.runner.visualstudio/2.4.1/build/netcoreapp1.0/xunit.runner.reporters.netcoreapp10.dll' is not located under the root directory '/var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src' and will not be analyzed.
WARNING: File '/var/lib/jenkins/.nuget/packages/xunit.runner.visualstudio/2.4.1/build/netcoreapp1.0/xunit.runner.utility.netcoreapp10.dll' is not located under the root directory '/var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src' and will not be analyzed.
Calling the SonarQube Scanner...
INFO: Scanner configuration file: /usr/local/sonar-scanner-msbuild/sonar-scanner-3.3.0.1492/conf/sonar-scanner.properties
INFO: Project root configuration file: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/sonar-project.properties
INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_252 Private Build (64-bit)
INFO: Linux 5.3.0-1019-aws amd64
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: SonarQube server 6.7.6
INFO: Default locale: "en", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=80ms
INFO: Server id: DA3BCEBC-AWdhK18pgdU_QI3j72wb
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=48ms
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=110ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=48ms
INFO: Load active rules
INFO: Load active rules (done) | time=743ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=35ms
INFO: Project key: TNCIT:WebBackend
INFO: -------------  Scan Css.Data.Services
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src/Css.Data.Services
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar/mod2
INFO: Source paths: [REMOVED LIST OF C# CODE FILES]
INFO: Source encoding: UTF-8, default locale: en
INFO: Load server rules
INFO: Load server rules (done) | time=127ms
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: Analyzer working directory contains 5 .pb file(s)
INFO: 73 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=13ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=2ms
INFO: -------------  Scan Css.WebServer
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src/Css.WebServer
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar/mod1
INFO: Source paths: [REMOVED LIST OF C# CODE FILES]
INFO: Source encoding: UTF-8, default locale: en
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: Analyzer working directory contains 5 .pb file(s)
INFO: 190 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=1ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=1ms
INFO: SCM provider for this project is: git
INFO: 3 files to be analyzed
INFO: 0/3 files analyzed
WARN: Missing blame information for the following files:
WARN:   * Css.WebServer/obj/Debug/netcoreapp3.0/.NETCoreApp,Version=v3.0.AssemblyAttributes.cs
WARN:   * Css.WebServer/obj/Debug/netcoreapp3.0/Css.WebServer.AssemblyInfo.cs
WARN:   * Css.WebServer/obj/Debug/netcoreapp3.0/Css.WebServer.MvcApplicationPartsAssemblyInfo.cs
WARN: This may lead to missing/broken features in SonarQube
INFO: -------------  Scan Css.EdwData
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src/Css.EdwData
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar/mod3
INFO: Source paths: [REMOVED LIST OF C# CODE FILES]
INFO: Source encoding: UTF-8, default locale: en
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: Analyzer working directory contains 5 .pb file(s)
INFO: 10 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
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: SCM provider for this project is: git
INFO: 2 files to be analyzed
INFO: 0/2 files analyzed
WARN: Missing blame information for the following files:
WARN:   * Css.EdwData/obj/Debug/netcoreapp3.0/.NETCoreApp,Version=v3.0.AssemblyAttributes.cs
WARN:   * Css.EdwData/obj/Debug/netcoreapp3.0/Css.EdwData.AssemblyInfo.cs
WARN: This may lead to missing/broken features in SonarQube
INFO: -------------  Scan Css.WebServer.Tests
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src/Css.WebServer.Tests
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar/mod4
INFO: Test paths: [REMOVED LIST OF C# CODE FILES]
INFO: Source encoding: UTF-8, default locale: en
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: Analyzer working directory contains 5 .pb file(s)
INFO: 8 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=105ms
INFO: Sensor XML Sensor [xml]
INFO: Sensor XML Sensor [xml] (done) | time=5ms
INFO: Sensor Analyzer for "php.ini" files [php]
INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=0ms
INFO: SCM provider for this project is: git
INFO: 1 files to be analyzed
INFO: 0/1 files analyzed
WARN: Missing blame information for the following files:
WARN:   * Css.WebServer.Tests/TestResults/TestResult.xml
WARN: This may lead to missing/broken features in SonarQube
INFO: -------------  Scan Css.Data
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src/Css.Data
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar/mod0
INFO: Source paths: [REMOVED LIST OF C# CODE FILES]
INFO: Source encoding: UTF-8, default locale: en
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: Analyzer working directory contains 5 .pb file(s)
INFO: 109 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Sensor C# [csharp] (done) | time=0ms
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: -------------  Scan Hub-Backend
INFO: Base dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/src
INFO: Working dir: /var/lib/jenkins/jobs/WebPipeline-Backend/workspace/.sonarqube/out/.sonar
INFO: Source encoding: UTF-8, default locale: en
INFO: Index files
INFO: Excluded sources:
INFO:   **/TestResults/TestResult.xml
INFO: 0 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
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=0ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=0ms
INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]
INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=60ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=1ms
INFO: Calculating CPD for 0 files
INFO: CPD calculation finished
INFO: Analysis report generated in 304ms, dir size=981 KB
INFO: Analysis reports compressed in 325ms, zip size=386 KB
INFO: Analysis report uploaded in 61ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard/index/TNCIT:WebBackend
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://localhost:9000/api/ce/task?id=AXNa7s6Iyx0pbtLeTien
INFO: Task total time: 5.740 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 7.233s
INFO: Final Memory: 18M/521M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
00:01:06.965  Post-processing succeeded.

Yes, all commands run from the same folder. As you can see, this is done in Jenkins and I’ve copied over the commands at the top of the post.

Regarding the SQ info:

INFO: SonarQube Scanner 3.3.0.1492
INFO: Java 1.8.0_252 Private Build (64-bit)
INFO: Linux 5.3.0-1019-aws amd64
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: SonarQube server 6.7.6

I hope this is all you asked for. Thanks @Andrei_Epure :slight_smile:

hi @EricBrian, apologies for the delay.

First, you are on an unsupported SQ version (6.7). The current supported LTS is SQ 7.9.

I’m afraid you didn’t provide the verbose logs as I suggested.

That is, in the BEGIN you should

            sh "dotnet '/usr/local/sonar-scanner-msbuild/SonarScanner.MSBuild.dll' begin /k:${SONARQUBEPROJECTKEY} /n:\"WebBackend\" /v:${env.BUILD_NUMBER} /d:sonar.login=\"${SQ_TOKEN}\" /d:sonar.verbose=true /d:sonar.links.homepage=\"http://<removed>:9000/dashboard?id=TNCIT%3AWebBackend\" /d:sonar.exclusions=\"**/TestResults/TestResult.xml\""

Also, why are you using “sonar.links.homepage” ? From the docs, I see it’s something for Maven. I would drop this if I were you.

Please also give the logs of the build step. Do you have access to the machine filesystem, to see what are the contents of <ANALYSIS_ROOT_DIR>\.sonarqube\out\0\FilesToAnalyze.txt ? Maybe you can, after the build step, print in the console output the contents of that file. If the file is empty, we need to investigate why. If the file is not empty and has all the scanned files, we need to understand why the C# sensor does not pick them up.

To explain what’s happening here:

  • in the Begin step, the scanner for msbuild sets up the parameters of the analysis and also injects an MSBuild target , in order for our C# analyzer to be picked up during the build and ran by MSBuild
  • in the build step, the analysis is done (via our C# analyzer which is a Roslyn Analyzer); the outputs of the analysis are put in .sonarqube\out\ - each project will have a folder starting from 0 (each project has a number assigned to it)
  • in the end step, the Scanner for MSBuild invokes the SonarQube Scanner which calls the C# Sensor which reads the data from .sonarqube\out and sends it to SonarQube

You can send a private message if you don’t want to put the paths to the files here in public. Click on my name and on Message, like below.

Based on your reply, I’ve:

  • added /d:sonar.verbose=true to the build command
  • removed sonar.links.homepage

I am sending you the output right now… Actually, I can not because:

You do not have a Message option in your profile popup.

Thanks for sending the logs privately. For the record and other users that may come to this post, the logs contained:

09:51:17.048 INFO: Sensor C# [csharp]
09:51:17.056 DEBUG: OS is not Windows. Skip Sensor.
09:51:17.059 INFO: Sensor C# [csharp] (done) | time=9ms

The used C# plugin version was SonarC# 6.5.0.3766 which is from October 2017 and back then it didn’t support cross-platform analysis (see this thread). In any case, as I said before, SQ 6.7 is not supported anymore. The currently supported LTS version of SQ is 7.9.

Please update to a supported version of our products and non-Windows analysis should work.

1 Like

Thank you very much, Andrei. I will talk to the maintainers about upgrading.

Again, thakn you!!!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.