JetBrains / TeamCity.SonarQubePlugin

A plugin for TeamCity server allowing you to configure and run SonarQube analysis from the CI
Apache License 2.0
53 stars 31 forks source link

integrating dotcover results in teamcity #20

Open harishrathi opened 8 years ago

harishrathi commented 8 years ago

I am not able to directly integrate dot-cover results in sonar-qube, but below commands did indeed helped

$Files= Get-ChildItem %system.teamcity.build.tempDir% ` 
    -Filter coverage_dotcover*.data ` 
    | where-object {$_.length -gt 50} ` 
    | Select-Object -ExpandProperty FullName 

$snapshot =[string]::Join(";",$Files) 

& %teamcity.tool.dotCover%\dotCover.exe merge ` 
  /Source=$snapshot ` 
  /Output=%env.TEMP%\dotCoverReport.dcvr` 

& %teamcity.tool.dotCover%\dotCover.exe report ` 
  /Source=%env.TEMP%\dotCoverReport.dcvr ` 
  /Output=%sonar.coverageReport% ` 
  /ReportType=HTML

I had took them from this SO answer

Can you have some option on UI which provides options for user to import coverage reports from... lets say dotcover or opencover etc, if user selects dotcover it should run above/some other appropriate script in background to generate results in a format that sonarqube understands

samgooch commented 8 years ago

Did you have any luck with this?

Linfar commented 6 years ago

Unfortunately I have little resources for the plugin. It becomes even worse knowing that SonarQube has tons of integrations with different tools which I could support. I will leave this ticket to track but can promise nothing on its timeline.

axel3rd commented 5 years ago

On TeamCity 2018.2.2 and/or bundled dotCover 2018.1.4, the .dcvr files seems directly in env.TEMP directory => the PowerShell script start should be:

$Files= Get-ChildItem %system.teamcity.build.tempDir% `
    -Filter "*.dcvr" `
    | where-object {$_.length -gt 50} `
    | Select-Object -ExpandProperty FullName
salamoun commented 2 years ago

%teamcity.tool.dotCover%\dotCover.exe works only on Windows Agents :(

axel3rd commented 1 year ago

Since TeamCity 2022.10 and depreciation of MSBuild runner in favor of .NET runner, the dotCover dcvr files are produced in the temps/agentTmp directory, which hasn't dedicated variable to be referenced => PowerShell script could be:

Write-Output "--- Retrieve 'dcvr' files to consider ---"
$Files = Get-ChildItem %env.TEMP%/../agentTmp -Recurse -Filter "*.dcvr" | where-object {$_.length -gt 50} | Select-Object -ExpandProperty FullName
Write-Output "$Files"
Write-Output "--- Generate string from list ---"
$Snapshot =[string]::Join(";",$Files)
Write-Output "$Snapshot"
Write-Output "--- Merge all 'dcvr' files in unique report ---"
& %teamcity.tool.dotCover%\dotCover.exe merge /Source=$Snapshot /Output=%env.TEMP%\sonarqube-dotCoverReport.dcvr
Write-Output "--- Generate HTML report understandable by SonarQube ---"
& %teamcity.tool.dotCover%\dotCover.exe report /Source=%env.TEMP%\sonarqube-dotCoverReport.dcvr /Output=%env.TEMP%\sonarqube-dotCover.html /ReportType=HTML

With Additional parameters in SonarQube analysis for MSBuild step:

/d:sonar.cs.dotcover.reportsPaths=%env.TEMP%\sonarqube-dotCover.html