No SCM was detected - jenkins

10:43:16.645 INFO - 0 files indexed
10:43:16.646 INFO - 0 files ignored because of inclusion/exclusion patterns
10:43:16.666 INFO - Quality profile for java: Sonar way
10:43:21.609 INFO - Sensor Lines Sensor
10:43:21.610 INFO - Sensor Lines Sensor (done) | time=1ms
10:43:21.610 INFO - Sensor SCM Sensor
10:43:21.610 INFO - No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
10:43:21.611 INFO - Sensor SCM Sensor (done) | time=1ms
10:43:21.611 INFO - Sensor XmlFileSensor

See "SonarQube doesn't show any issues with Maven project", and check your Sonar server: log in as administrator, click on Settings, then System, then Update Center.
Check if the Sonar Java plugin is installed. If not, click on Available Plugins to download and install it.

Related

Sonar test coverage sensor being ran on Pull Request only

I have a jenkins multi-pipeline project setup doing sonar scans with PR decoration.
When a pull request is scanned sonar correctly runs the test coverage report sensor and coverage is reported correctly.
However when this is merged back to our main the sensor just isn't being ran.
PR Branch:
....
INFO: Importing 34 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=8804ms
INFO: Sensor C# Tests Coverage Report Import [csharp]
INFO: Parsing the OpenCover report C:\Jenkins\workspace\Build-API_PR-273\.\Tests\SharedDataServices.Tests\coverage.opencover.xml
....
Main Branch:
....
INFO: Importing 34 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=13859ms
INFO: Sensor JavaSecuritySensor [security]
....
As you can see it completely omits the sensor.
Things I've checked:
Pull request works and coverage is being reported fine
The reports are being generated in the same relative locations on Main
The contents of the reports are not empty
The contents of the reports refer correctly to the tested .cs files
Any ideas or tips please?

SonarQube plug-in not scanning C# files during TFS Build

I am running SonarQube server v6.4 with v6.1 of the C# plugin. We have v3.0.0 of the SonarQube TFS extension installed in our TFS 2015 (Update 3) instance.
I am having issues with SonarQube scanning .cs files. There are a few warnings in the output of a few build steps that I'm not entirely sure what to make of. I haven't been able to find much on the messages.
Visual Studio Build step output:
OverrideCodeAnalysisProperties:
Skipping FxCop analysis: the SonarQube ruleset does not exist. Ruleset: C:\BuildAgents\Agent-01\_work\111\.sonarqube\conf\\SonarQubeFxCop-cs.ruleset
SonarQube Scanner for MSBuild - End Analysis (new) step output:
I'm seeing this at the beginning of the output for the step...
SonarQube Scanner for MSBuild 3.0
Default properties file was found at C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Loading analysis properties from C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\SonarQube.Analysis.xml
Post-processing started.
17:58:54.965 17:58:54.965 WARNING: Failed to find the code coverage command line tool. Possible cause: Visual Studio is not installed, or the installed version does not support code coverage.
WARNING: File is not under the project directory and cannot currently be analysed by SonarQube. File: C:\Users\TFS2015Build\AppData\Local\Temp\.NETFramework,Version=v4.5.2.SqlClrAttributes.cs, project: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Db\FunProject.Db.sqlproj
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\BuildAgents\Agent-01\tasks\SonarQubeScannerMsBuildBegin\3.0.0\SonarQubeScannerMsBuild\sonar-scanner-3.0.3.778\bin\..\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.0.3.778
INFO: Java 1.8.0_121 Oracle Corporation (64-bit)
INFO: Windows Server 2012 R2 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache
INFO: Load global settings
INFO: Load global settings (done) | time=125ms
INFO: User cache: C:\Users\TFS2015Build\.sonar\cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=0ms
INFO: Download sonar-csharp-plugin-6.1.0.2359.jar
INFO: Download sonar-python-plugin-1.8.0.1496.jar
INFO: Download sonar-java-plugin-4.11.0.10660.jar
INFO: Download sonar-flex-plugin-2.3.jar
INFO: Download sonar-scm-git-plugin-1.2.jar
INFO: Download sonar-xml-plugin-1.4.3.1027.jar
INFO: Download sonar-php-plugin-2.10.0.2087.jar
INFO: Download sonar-scm-svn-plugin-1.4.0.522.jar
INFO: Download sonar-javascript-plugin-3.1.1.5128.jar
INFO: SonarQube server 6.4.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=141ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=47ms
INFO: Load active rules
INFO: Load active rules (done) | time=281ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=78ms
INFO: Publish mode
...then I'm seeing a set of output like this for each project in my solution:
INFO: ------------- Scan FunProject.Shared
INFO: Load server rules
INFO: Load server rules (done) | time=156ms
INFO: Initializer GenericCoverageSensor
INFO: Initializer GenericCoverageSensor (done) | time=0ms
INFO: Base dir: C:\BuildAgents\Agent-01\_work\111\s\FunProject.Shared
INFO: Working dir: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\.sonar\mod13
INFO: Source paths: FunProjectFolder1/FunProjectClassFile1.cs, FunProjectFolder2/FunProjectClassFile2.cs, ... Properties/AssemblyInfo.cs, packages.config
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Analyzer working directory does not exist
INFO: 12 files indexed
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# [csharp]
INFO: Importing analysis results from C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\encoding.pb
INFO: Importing Roslyn report
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\metrics.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-type.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\symrefs.pb
WARNING: WARN: Protobuf file not found: C:\BuildAgents\Agent-01\_work\111\.sonarqube\out\FunProject.Shared_3389\output-cs\token-cpd.pb
INFO: Sensor C# [csharp] (done) | time=78ms
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
Is there something obvious that I'm missing?
Edit:
I am using Visual Studio Professional, so the warning about code coverage is caused by the fact that I do not have Visual Studio Enterprise installed on the build server.
Suggest you first try to analyze solution in the command line locally to see if it works.
Run your analysis by executing the following commands from the root directory of the project:
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
This will narrow down it's your environment issue or just related to your build definition settings.
According to the error message:
WARNING: Failed to find the code coverage command line tool. Possible
cause: Visual Studio is not installed, or the installed version does
not support code coverage.
Double check your VS edition on your build agent. Note: you need Visual Studio Enterprise edition for code coverage. Have a look at this page and expand the 'testing tools' section. Code coverage is only listed for the Enterprise edition.
Besides, you could also enable verbose Debug Mode with system.debug=true to get a more detail build log for troubleshooting.
I downgraded the C# plugin from 6.1 (build 2359) to 5.11 (build 1721), and the problem went away. There must be some issue with that release that was causing the issue.

WARN: Protobuf file not found, when using SonarQube

I'm just getting started with SonarQube and it does run so far.
The IT department has set up SonarQube 6.2 for our Team Foundation Server and I have installed and configured the msbuild scanner on my BuildAgent.
I call the msbuild scanner in the XAML-Template of my build definition and it does run, but it gives me a warning, which makes my build "partially succeeded".
This is the error message:
07:53:01.658 WARN: Protobuf file not found:
d:\b\210\474.sonarqube\out\ReferenceManager_x86_Release_6561\output-cs\issues.pb
The issues.pb file is really missing, but why do I get an error/warning for this? I do not get this, when I run the scanner and msbuild from command line, only when in runs in team build. But when running on command line there also is no issues.pb file.
When running the scanner from the command line, I get this output:
09:34:05.959 INFO: 97 files indexed
09:34:05.985 INFO: Quality profile for cs: Sonar way
09:34:05.992 DEBUG: Code colorizer, supported languages:
09:34:07.008 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
09:34:07.009 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
09:34:07.018 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
09:34:07.023 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
09:34:07.025 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
09:34:07.027 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
09:34:07.029 INFO: Sensor Lines Sensor
09:34:07.279 INFO: Sensor Lines Sensor (done) | time=250ms
09:34:07.279 INFO: Sensor SCM Sensor
09:34:07.279 INFO: SCM Publisher is disabled
09:34:07.281 INFO: Sensor SCM Sensor (done) | time=2ms
09:34:07.281 INFO: Sensor C#
09:34:07.292 INFO: SonarAnalyzer.Scanner needs to be executed: false
09:34:07.292 INFO: Importing analysis results from C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\ReferenceManager_x86_Release_5730\output-cs
09:34:08.749 INFO: Importing Roslyn report
09:34:08.998 INFO: Sensor C# (done) | time=1717ms
When running the scanner during team build, I get this output:
11:12:51.390 INFO: 97 files indexed
11:12:51.422 INFO: Quality profile for cs: Sonar way
11:12:51.422 DEBUG: Code colorizer, supported languages:
11:12:52.468 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'Generic Test Executions Report' skipped because one of the required properties is missing
11:12:52.468 DEBUG: 'SurefireSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JaCoCoSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaSquidSensor' skipped because there is no related file in current project
11:12:52.468 DEBUG: 'JavaScript Squid Sensor' skipped because there is no related file in current project
11:12:52.484 DEBUG: Sensors : Lines Sensor -> SCM Sensor -> C# -> Coverage Report Import -> Coverage Report Import -> Unit Test Results Import -> XmlFileSensor -> Zero Coverage Sensor -> Code Colorizer Sensor -> CPD Block Indexer
11:12:52.484 INFO: Sensor Lines Sensor
11:12:52.562 INFO: Sensor Lines Sensor (done) | time=78ms
11:12:52.562 INFO: Sensor SCM Sensor
11:12:52.562 INFO: SCM Publisher is disabled
11:12:52.562 INFO: Sensor SCM Sensor (done) | time=0ms
11:12:52.562 INFO: Sensor C#
11:12:52.562 INFO: SonarAnalyzer.Scanner needs to be executed: false
11:12:52.562 INFO: Importing analysis results from d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs
11:12:53.078 WARN: Protobuf file not found: d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs\issues.pb
11:12:53.718 INFO: Sensor C# (done) | time=1156ms
Didn't find anything about this error using google. Any help appreciated!
By looking at the code in CSharpSencor.java, I think the difference between command line build and team build is caused by the RoslynReportPath:
void executeInternal(SensorContext context) {
boolean requiresAnalyzerScannerExecution = !config.isReportsComingFromMSBuild();
LOG.info("SonarAnalyzer.Scanner needs to be executed: " + requiresAnalyzerScannerExecution);
String roslynReportPath = settings.getString(config.getRoslynJsonReportPathProperty());
boolean hasRoslynReportPath = roslynReportPath != null;
Path protobufReportsDirectory;
if (requiresAnalyzerScannerExecution) {
// MSBuild 12 or MSBuild 14 with old scanner
analyze(!hasRoslynReportPath, context);
protobufReportsDirectory = protobufReportPathForMSBuild12(context);
} else {
protobufReportsDirectory = config.protobufReportPathFromScanner();
}
LOG.info("Importing analysis results from " + protobufReportsDirectory.toAbsolutePath().toString());
importResults(context, protobufReportsDirectory, !hasRoslynReportPath);
if (hasRoslynReportPath) {
LOG.info("Importing Roslyn report");
importRoslynReport(roslynReportPath, context);
}
}
command line build:
...
Generating SonarQube project properties file to C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\sonar-project.properties
The supplied Code Analysis ErrorLog file is a valid json file and does not need to be fixed: d:\b\210\474\src\TPA\DevTools_Source\internal\ReferenceManager\main\ReferenceManager\bin\Release\ReferenceManager.exe.RoslynCA.json
...
08:41:57.276 INFO: Sensor C#
08:41:57.291 INFO: SonarAnalyzer.Scanner needs to be executed: false
08:41:57.291 INFO: Importing analysis results from C:\Users\Build-SW-Dev\Desktop\.sonarqube\out\ReferenceManager_x86_Release_6194\output-cs
08:41:59.948 INFO: Importing Roslyn report
08:42:00.448 INFO: Sensor C# (done) | time=3172ms
team build:
...
Generating SonarQube project properties file to d:\b\210\474\.sonarqube\out\sonar-project.properties
No Code Analysis ErrorLog file found at d:\b\210\474\bin\ReferenceManager.exe.RoslynCA.json.
...
11:12:52.562 INFO: Sensor C#
11:12:52.562 INFO: SonarAnalyzer.Scanner needs to be executed: false
11:12:52.562 INFO: Importing analysis results from d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs
11:12:53.078 WARN: Protobuf file not found: d:\b\210\474\.sonarqube\out\ReferenceManager_x86_Release_1481\output-cs\issues.pb
11:12:53.718 INFO: Sensor C# (done) | time=1156ms
While I do not have a solution to that yet, a workaround is to just redirect the output of the msbuild scanner into a file. TFS then does not see the warning and does not make the build partially succeeded.
edit:
Now I have found the root cause :) During team build, all output files get moved into a subfolder by a script. That's why SonarQube cannot find the file 'd:\b\210\474\bin\ReferenceManager.exe.RoslynCA.json'.
The file is located in a subfolder...

The SonarQube Post-build Action is deprecated

Using Jenkins 1.642.2 for code analysis with SonarQube 5.6.1 for all my maven projects.
When I use maven goal sonar:sonar they take more time to analyse files (more than 7 seconds by file) :
[INFO] Sensor SCM Sensor
[INFO] SCM provider for this project is: svn
[INFO] 1079 files to be analyzed
[INFO]
[INFO] 2/1079 files analyzed
[INFO] 3/1079 files analyzed
[INFO] 4/1079 files analyzed
[INFO] 5/1079 files analyzed
When I use the SonarQube Scanner with this config :
then i have this error :
WARN: Property 'sonar.jdbc.url' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.username' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
WARN: Property 'sonar.jdbc.password' is not supported any more. It will be ignored. There is no longer any DB connection to the SQ database.
INFO: User cache: /var/lib/jenkins/.sonar/cache
INFO: Load plugins index
INFO: Load plugins index (done) | time=43ms
INFO: SonarQube server 5.6.1
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Process project properties
INFO: ---------------------------------------------------------------------- --
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1.621s
INFO: Final Memory: 39M/132M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
ERROR: You must define the following mandatory properties for 'Unknown': sonar.projectKey, sonar.projectName, sonar.projectVersion, sonar.sources
ERROR:
ERROR: Re-run SonarQube Scanner using the -X switch to enable full debug logging.
Build step 'Execute SonarQube Scanner' marked build as failure
Finished: FAILURE
My settings file :
<profile>
<id>sonar</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<sonar.jdbc.url>
jdbc:mysql://11.230.5.88:3306/sonar
</sonar.jdbc.url>
<sonar.jdbc.username>sonar</sonar.jdbc.username>
<sonar.jdbc.password>sonar</sonar.jdbc.password>
<!-- Optional URL to server. Default value is http://localhost:9000 -->
<sonar.host.url>
http://sonarqube-groupe.com/
</sonar.host.url>
</properties>
</profile>
Any idea to solve this problem because i have a problem to understand the new sonarqube use
i must make a sonar-project.properties file for the maven project?
You can and should still analyze with Maven, using a Build Step. As stated in the docs, you should first "Enable injection of SonarQube server configuration" at the global configuration level, and then in your build enable the Build Environment Option "Prepare SonarQube Scanner environment". Then you can set your Maven goal to the following:
$SONAR_MAVEN_GOAL -Dsonar.host.url=$SONAR_HOST_URL -Dsonar.login=$SONAR_AUTH_TOKEN

clover.xml not found - Jenkins Build

after changing to SonarRunner for my Jenkins-Builds there is a problem with my automatically generated reports.
I generate these reports from the clover.xml but I got this problem in my Jenkins Job:
13:15:00.760 INFO - Sensor org.sonar.plugins.clover.CloverSensor
13:15:00.760 WARN - Clover XML report not found
13:15:00.760 INFO - Sensor org.sonar.plugins.clover.CloverSensor (done) | time=1ms
13:15:00.760 INFO - Sensor SurefireSensor
13:15:00.761 INFO - parsing d:\seu\jenkins\workspace\dev2015.0.0 module.fakturierung.Buch.Tabelle.Test.Testjob\target\surefire-reports
13:15:00.761 ERROR - Reports path not found or is not a directory: d:\seu\jenkins\workspace\dev2015.0.0 module.fakturierung.Buch.Tabelle.Test.Testjob\target\surefire-reports
13:15:00.761 INFO - Sensor SurefireSensor (done) | time=1ms
Here my sonar-project.properties:
# required metadata
sonar.projectKey=de.adnova:module.fakturierung:test
sonar.projectName=module.fakturierung Testjob
sonar.projectVersion=2015.0.0-SNAPSHOT
# path to source directories (required)
sonar.sources=src/module.fakturierung
# exclusions from path
sonar.exclusions=**/src/generated/java/**, **/test/**, **/clover/**
#clover
sonar.java.coveragePlugin=clover
sonar.clover.reportPath= D:/SEU/Jenkins/workspace/dev2015.0.0 module.fakturierung.Buch.Tabelle.Test.Testjob/src/module.fakturierung/target/site/clover/clover.xml
SonarQube 5.2 (Clover-Plugin 3.1)
Maven 2.3
I tried a lot but nothing worked.Thanks!

Resources