Cannot send build results to SonarQube server - c#

I'm working on a POC and I'm able to create a project and send the build results to SonarQube localhost server without any errors.
But when I build the same project and send the the results to production server, build will succeed but the results on the server is empty.
In the server, I'm getting the following warning.
SCM provider autodetection failed. Please use “sonar.scm.provider” to define SCM of your project, or disable the SCM Sensor in the project settings.
I found that, its not creating the output-cs folder. when i run these commands in local its creating those files and folders but for production server its not.
Path to output-cs
C:\Users\Administrator\Desktop\my-project.sonarqube\out\0
Code I ran for localhost:
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe begin
/k:"my-test-project" /d:sonar.verbose=true /d:sonar.host.url="http://localhost:9000"
/d:sonar.login="project-token"
MsBuild.exe /t:Rebuild
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe end
/d:sonar.login="project-token"
Code I ran for Production Sever:
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe begin
/k:"my-test-project" /d:sonar.verbose=true /d:sonar.host.url="http://prod-server-url"
/d:sonar.login="sonarqube_project_token"
MSBuild.exe /t:Rebuild
C:\Users\Administrator\Desktop\sonar-scanner-msbuild-5.1.0.28487-net46\SonarScanner.MSBuild.exe end
/d:sonar.login="sonarqube_project_token"
Difference between those two codes is only the SonarQube project name and token only.
I went through the build stack trace and found some warnings.
WARN: No coverage report can be found with
sonar.coverage.jacoco.xmlReportPaths='build/reports/jacoco/test/jacocoTestReport.xml'.
Using default locations:
target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
Doubt:
Do we need to specifically mention some additional parameters when building for server compared to localhost?
Note: This is c# application.

Related

Getting error while running SonarScannerMSBuild on Xamarin projects

1) When I Try to use Rebuild option
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/MSBuild.SonarQube.Runner.exe /t:Rebuild
WARNING: ------------------------------------------------------------------------
This executable is deprecated and may be removed in next major version of the SonarScanner for MSBuild. Please use 'SonarScanner.MSBuild.exe' instead.
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
WARNING: Please specify the command 'begin' or 'end' to indicate whether pre- or post-processing is required. These parameters will become mandatory in a later release.
Pre-processing started.
Preparing working directories...
05:23:39.463 05:23:39.454 Unrecognized command line argument: /t:Rebuild
05:23:39.464 05:23:39.462 A required argument is missing: /key:[SonarQube project key]
05:23:39.464 Expecting at least the following command line argument:
SonarQube project key
When connecting to a SonarQube server earlier than version 6.1, the following command line arguments are also required:
SonarQube project name
SonarQube project version
The full path to a settings file can also be supplied. If it is not supplied, the exe will attempt to locate a default settings file in the same directory as the SonarQube Scanner for MSBuild.
Use '/?' or '/h' to see the help message.
05:23:39.464 Pre-processing failed. Exit code: 1
2) I get some other error with authentication problems. Any work around this.
MANOJs-MacBook-Air:UI_Testing2 manojdeshpande$ mono /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarScanner.MSBuild.exe begin /k:"Xamarin" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token1"
SonarScanner for MSBuild 4.5
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Loading analysis properties from /Users/manojdeshpande/Downloads/sonar-scanner-msbuild-4.5.0.1761-net46/SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
05:18:52.798 Updating build integration targets...
05:18:52.833 Fetching analysis configuration settings...
05:18:52.94 Failed to request and parse 'http://localhost:9000/api/settings/values?component=Xamarin': The remote server returned an error: (401) .
05:18:52.94 Could not authorize while connecting to the SonarQube server. Check your credentials and try again.
05:18:52.941 Pre-processing failed. Exit code: 1

VSTS Release Failing due to file in use on remote server

Before I state the question I am aware this may be more of a server administration question however I am seeking an answer that involves fixing / modifying the VSTS release process instead of dealing with server permissions (I don't believe this is a server issue).
I have a VSTS Build definition and Release definition.
The release definition copies the files from the build to a remote server (an IIS site).
My problem is that this process fails roughly 60% of the time.
Log files showing failure error:
2017-04-06T17:06:07.3886551Z Executing the powershell script: D:\BuildAgent\agent\tasks\IISWebAppDeploy\1.4.3\Main.ps1
2017-04-06T17:06:07.5605268Z Starting deployment of IIS Web Deploy Package : \\server01\Deploy\patrol\dev\rest_service\822\822.zip
2017-04-06T17:06:07.6542742Z Performing deployment in parallel on all the machines.
2017-04-06T17:06:07.6542742Z Deployment started for machine: SERVER01 with port 5985.
2017-04-06T17:06:27.9820654Z Deployment status for machine SERVER01 : Failed
2017-04-06T17:06:28.0133029Z Deployment failed on machine SERVER01 with following message : System.Exception: Error Code: ERROR_FILE_IN_USE
2017-04-06T17:06:28.0445759Z ##[error]Microsoft.PowerShell.Commands.WriteErrorException: Deployment on one or more machines failed.
2017-04-06T17:06:28.0445759Z ##[error]For more info please refer to http://aka.ms/iisextnreadme
I circumvate the problem by manually remoting into the server and deleting the contents of the target directory manually. I've discovered that each time the release is failing, my manual delete causes a warning to popup that an .exe file is being used by another process. My suspicion is that this is the reason the release is failing.
Is there some extra step that can be added to a release to force delete / clear the target directory?
You can use Windows Machine File Copy task to copy files from build to a remote server. And select Clean Target so that before copy files to remote server, it will clean the target destination folder firstly.

SonarQube MSBuild Runner defaults to h2 Database

I am using Win Server 2012, Developer Command Prompt for VS2013, SonarQube v5.1.2, SonarQube Scanner for MSBuild 1.1.
I have my Sonar instance running off this same server, but connected to an Oracle database. Using the default sonar runner, i can analyze projects properly and see them appear in the dashboard using this method. That cannot be said for using the recommended MSBuild.SonarQube.Runner.exe approach.
I have tried with the csharp and vbnet examples, as well as our actual code. Oddly, i want to say each of these have worked at least once, but fail to do so now. Today, I tried using the vbnet example project for the first time and discovered and it worked as intended when using the MSBuild runner. I deleted the project from the dashboard, and ran it again. At this point i do not remember it it worked or not, but the third time for sure it stopped working and began producing the error below (wherein it tries to connect to the default h2 database instead of the oracle one that SonarQube is connected to).
I tried deleting the examples folder, extracting it again, giving it a slightly different name, and running the Sonar on it giving THOSE a different name/key/version, but now it is consistently giving me the db error.
Any idea what could be going on here, and why it would go from working to not, without me making any changes to the runner, msbuild, or the code?
Running the begin step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe b
egin /v:vbnet1 /k:vbnet1 /n:vbnet1
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
Checking for updates...
MSBuild SonarQube Runner Pre-processor 1.0.2.0
17:40:49.625 Loading analysis properties from c:\sonarqube\bin\SonarQube.Analys
is.xml
17:40:49.656 Updating build integration targets...
17:40:49.656 Fetching analysis configuration settings...
17:40:50.813 Generating rulesets...
Pre-processing succeeded.
MSBuild ran, but nothing worthwhile to post from it..
Running the end step:
c:\sonar-examples-master\projects\languages\vbnet>msbuild.sonarqube.runner.exe e
nd
SonarQube Scanner for MSBuild 1.1
Default properties file was found at c:\sonarqube\bin\SonarQube.Analysis.xml
Loading analysis properties from c:\sonarqube\bin\SonarQube.Analysis.xml
Post-processing started.
MSBuild SonarQube Runner Post-processor 1.0.2.0
WARNING: File is not under the project directory and cannot currently be analyse
d by SonarQube. File: C:\Users\ts3conusr\AppData\Local\Temp\.NETFramework,Versio
n=v4.5.AssemblyAttributes.vb, project: c:\sonar-examples-master\projects\languag
es\vbnet\ConsoleApplication1\ConsoleApplication1.vbproj
The SONAR_RUNNER_HOME environment variable is not required and will be ignored.
SONAR_RUNNER_OPTS is not configured. Setting it to the default value of -Xmx1024
m
Calling the sonar-runner...
c:\sonar-examples-master\projects\languages\vbnet\.sonarqube\bin\sonar-runner\bi
n\..
SonarQube Runner 2.4
Java 1.7.0_79 Oracle Corporation (32-bit)
Windows Server 2008 R2 6.1 x86
SONAR_RUNNER_OPTS=-Xmx1024m
INFO: Error stacktraces are turned on.
INFO: Runner configuration file: c:\sonar-examples-master\projects\languages\vbn
et\.sonarqube\bin\sonar-runner\bin\..\conf\sonar-runner.properties
INFO: Project configuration file: c:\sonar-examples-master\projects\languages\vb
net\.sonarqube\out\sonar-project.properties
INFO: Default locale: "en_US", source code encoding: "UTF-8"
INFO: Work directory: c:\sonar-examples-master\projects\languages\vbnet\.sonarqu
be\out\.sonar
INFO: SonarQube Server 5.1.2
17:41:04.563 INFO - Load global repositories
17:41:04.751 INFO - Load global repositories (done) | time=188ms
17:41:04.751 INFO - Server id: 20160120154951
17:41:04.751 INFO - User cache: C:\Users\ts3conusr\.sonar\cache
17:41:04.766 INFO - Install plugins
17:41:04.860 INFO - Install JDBC driver
17:41:04.860 INFO - Create JDBC datasource for jdbc:h2:tcp://localhost/sonar
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
Total time: 1.047s
Final Memory: 3M/15M
INFO: ------------------------------------------------------------------------
ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
Of note: I feel that it is worth mentioning that the vbnet report didn't actually have any content in it, but did at least properly get generated in the Sonar dashboard. I have tried running the commands against both that and the csharp example with now neither of them being added to the dashboard.
In the MSBuild.SonarQube.Runner install folder, there is a SonarQube.Analysis.xml. Do you have the correct server details on the below line in there?
<Property Name="sonar.host.url">http://{host}:{port}/{optionalPath}</Property>
This property value should point to your Sonar server.
Couple other things to try. Do you see tables being populated with analysis data in your oracle database? When was the last time it got any record?
Also, are you seeing below warning on your SonarQube application pages (say default dashboard)? If yes, then oracle configuration is not being picked up.
So i upgraded to the latest SonarQube version (5.3) and upgraded a few of the extensions while i was at it and preliminary testing is showing positive results. Ill try it a few more times but im closing the question for now. Thank you all that helped!

Failed to convert the downloaded code coverage tool to XML

I have code coverage enabled on TFS 2013. I work with MSBuild.SonarQube.Runner 1.0.1. When I run the End phase of the Analysis. I get the following error messages:
11:36:00.269 Failed to convert the downloaded code coverage tool to XML. No code coverage information will be uploaded to SonarQube.<br/>
Check that the downloaded code coverage file (C:\Builds\39\[product name]\System_Main_Release_Code_Analysis\.sonarqube\out\VSCodeCoverageReport.coverage) is valid by opening it in Visual Studio. If it is not, check that the internet security settings on the build machine allow files to be downloaded from the Team Foundation Server machine.
Post-processing failed. Exit code: 1
An error occurred while copying diagnostic activity logs to the drop location. Details: Forbidden
On the build server there is no VSCodeCoverageReport.coverage file - at least not at the indicated location and with that name. However, when I click on (Coverage Results) in the TFS Build summary, a coverage file is downloaded that opens up in Visual Studio in the Code Coverage Results Window.
What could be the issue?
The problem is solved.
The proxy settings on the build agent had changed. This resulted in http requests to the TFS server or any local addresses to fail.
It was particularly challanging to figure out, because the Agent build log that tells you all the details of a build is the file that could not be transferred to the drop location. So I used ProcMon from Sysinternals with File monitor enabled during a build. A comparison between a successful build in the past and a current failed build showed me which file was missing (the agent log file). A search in ProcMon for this file revealed where that file was located on the build agent. The Agent Log file contained the Downloading coverage file from {0} to {1} line Dinesh was looking for in his attempt to help me. That http address pasted into a browser showed an "Access denied" message.
From there it was a logical step to analyse the Proxy settings. What finally solved it was to check "Bypass proxy server for local addresses" in the Local Area Network (LAN) Settings"

Git not found in path by SonarQube using Jenkins

My setup is as follows:
Jenkins on Windows Server 2012 system
Git installed on the same system
SonarQube on separate server, executed by SonarQube Runner (not Maven)
I have a Jenkins project that pulls source code (C#) using Git, compiles it, then presents it for analysis to SonarQube. The pull, compile, and analysis all work, but I am getting error messages saying:
16:05:58.883 INFO - Retrieve SCM info for (source file path)
16:05:58.883 WARN - Fail to retrieve SCM info of: (source file path) Reason: The git blame command failed. 'git' is not recognized as an internal or external command,
operable program or batch file.
I first assumed that Git had to be installed on the SonarQube server, too, but there is another project using a similar setup and the same SonarQube server that is working correctly, adding "blame" information to SonarQube's source code listings.
What am I missing?

Categories

Resources