Sonarqube没有显示任何c#问题

时间:2017-07-03 22:56:31

标签: c# sonarqube

我在安装Jenkins的同一台机器上安装了Sonarqube。每次推出gitlab时,我都会开始构建,构建运行并且声纳报告正确的构建。

但是我添加了与当前配置文件不兼容的代码(c#的默认设置)。

Sonar.project-propertries:

sonar.projectKey=devkey:develop
sonar.projectName=FML
sonar.projectVersion=master

sonar.sources=.
sonar.language=cs
sonar.sourceEncoding=UTF-8

构建日志:

22:43:34 [ExampleJob] $ /opt/sonar-scanner-3.0.3.778-linux/bin/sonar-scanner 
-e -Dsonar.host.url=http://........... ******** -
Dsonar.projectBaseDir=/var/lib/jenkins/workspace/ExampleJob
22:43:34 INFO: Option -e/--errors is no longer supported and will be ignored
22:43:34 INFO: Scanner configuration file: /opt/sonar-scanner-3.0.3.778-
linux/conf/sonar-scanner.properties
22:43:34 INFO: Project root configuration file: /var/lib/jenkins/workspace/ExampleJob/sonar-project.properties
22:43:34 INFO: SonarQube Scanner 3.0.3.778
22:43:34 INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
22:43:34 INFO: Linux 3.13.0-119-generic amd64
22:43:35 INFO: User cache: /var/lib/jenkins/.sonar/cache
22:43:36 INFO: Load global settings
22:43:36 INFO: Load global settings (done) | time=134ms
22:43:36 INFO: User cache: /var/lib/jenkins/.sonar/cache
22:43:36 INFO: Load plugins index
22:43:36 INFO: Load plugins index (done) | time=5ms
22:43:37 INFO: SonarQube server 6.4.0
22:43:37 INFO: Default locale: "en_US", source code encoding: "UTF-8"
22:43:37 INFO: Process project properties
22:43:38 INFO: Load project repositories
22:43:38 INFO: Load project repositories (done) | time=150ms
22:43:38 INFO: Execute project builders
22:43:38 INFO: Execute project builders (done) | time=1ms
22:43:38 INFO: Load quality profiles
22:43:38 INFO: Load quality profiles (done) | time=29ms
22:43:38 INFO: Load active rules
22:43:39 INFO: Load active rules (done) | time=515ms
22:43:39 INFO: Load metrics repository
22:43:39 INFO: Load metrics repository (done) | time=112ms
22:43:39 INFO: Publish mode
22:43:39 INFO: Project key: devkey:develop
22:43:39 INFO: -------------  Scan FML
22:43:39 INFO: Load server rules
22:43:39 INFO: Load server rules (done) | time=101ms
22:43:39 INFO: Language is forced to cs
22:43:39 INFO: Initializer GenericCoverageSensor
22:43:39 INFO: Initializer GenericCoverageSensor (done) | time=0ms
22:43:39 INFO: Base dir: /var/lib/jenkins/workspace/ExampleJob
22:43:39 INFO: Working dir: /var/lib/jenkins/workspace/ExampleJob/.scannerwork
22:43:39 INFO: Source paths: .
22:43:39 INFO: Source encoding: UTF-8, default locale: en_US
22:43:39 INFO: Index files
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/Assets/TestScript.cs.meta' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/Assets/SceneViewWindow.cs.meta' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/GraphicsSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/Physics2DSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/ClusterInputManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/AudioManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/EditorBuildSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/DynamicsManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/QualitySettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/NetworkManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/TagManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/InputManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/UnityConnectSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/EditorSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/NavMeshAreas.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/TimeManager.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/ProjectSettings.asset' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/TestProj/ProjectSettings/ProjectVersion.txt' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/sonar-project.properties' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 WARN: File '/var/lib/jenkins/workspace/ExampleJob/README.md' is ignored because it doesn't belong to the forced language 'cs'
22:43:40 INFO: 2 files indexed
22:43:40 INFO: Quality profile for cs: Sonar way
22:43:41 INFO: Sensor C# [csharp]
22:43:41 INFO: Sensor C# [csharp] (done) | time=11ms
22:43:41 INFO: Sensor SonarJavaXmlFileSensor [java]
22:43:41 INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
22:43:41 INFO: Sensor Analyzer for "php.ini" files [php]
22:43:41 INFO: Sensor Analyzer for "php.ini" files [php] (done) | time=8ms
22:43:41 INFO: Sensor C# Unit Tests Coverage Report Import [csharp]
22:43:41 INFO: Sensor C# Unit Tests Coverage Report Import [csharp] (done) | time=0ms
22:43:41 INFO: Sensor C# Integration Tests Coverage Report Import [csharp]
22:43:41 INFO: Sensor C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms
22:43:41 INFO: Sensor C# Unit Test Results Import [csharp]
22:43:41 INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms
22:43:41 INFO: Sensor Zero Coverage Sensor
22:43:41 INFO: Sensor Zero Coverage Sensor (done) | time=21ms
22:43:41 INFO: Sensor CPD Block Indexer
22:43:41 INFO: Sensor CPD Block Indexer (done) | time=1ms
22:43:42 INFO: SCM provider for this project is: git
22:43:42 INFO: 2 files to be analyzed
22:43:42 INFO: 2/2 files analyzed
22:43:42 INFO: Calculating CPD for 0 files
22:43:42 INFO: CPD calculation finished
22:43:42 INFO: Analysis report generated in 144ms, dir size=23 KB
22:43:42 INFO: Analysis reports compressed in 19ms, zip size=7 KB
22:43:43 INFO: Analysis report uploaded in 381ms
22:43:43 INFO: ANALYSIS SUCCESSFUL, you can browse http://.............
22:43:43 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
22:43:43 INFO: More about the report processing at http://.............
22:43:43 INFO: Task total time: 5.951 s
22:43:43 INFO: ------------------------------------------------------------------------
22:43:43 INFO: EXECUTION SUCCESS
22:43:43 INFO: ------------------------------------------------------------------------
22:43:43 INFO: Total time: 8.665s
22:43:43 INFO: Final Memory: 46M/198M
22:43:43 INFO: ------------------------------------------------------------------------
22:43:44 Finished: SUCCESS

1 个答案:

答案 0 :(得分:0)

您不应该将SonarQube扫描仪用于C#,而是SonarQube Scanner for MSBuild。为什么?因为C#项目通常非常难以手动配置属性文件。配置错误可能就是您遇到的问题。

使用SonarQube扫描仪进行MSBuild,您可以使用扫描仪开始和结束调用来构建您的构建,如下所示:

SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"Project Name" /v:"1.0"
MSBuild.exe /t:Rebuild
SonarQube.Scanner.MSBuild.exe end

使用SonarQube扫描仪进行MSBuild,您不需要属性文件。大多数值都是从解决方案文件中读取的,其余值是在初始命令行上传递的,如上所示。