Tsql code coverage report is not publishing in sonarcloud

Template for a good new topic, formatted with Markdown:

  • Azure devops
  • Trying to run unit test with code coverage for SQL database with SQL cover
  • Using sql cover script i can now publish the code coverage result in ADO summary
  • But while trying to publish the result in sonar cloud getting 0.0% as result
* steps:
- task: SonarSource.sonarcloud.14d9cde6-c1da-4d55-aa01-2965cd301255.SonarCloudPrepare@3
  displayName: 'Prepare analysis on SonarQube Cloud'
  inputs:
    SonarQube: SonarCloud
    organization: msc
    scannerMode: cli
    configMode: manual
    cliProjectKey: ''
    cliProjectName: ''
    cliSources: DatabaseTest
    extraProperties: |
     sonar.scanner.scanAll=false
     sonar.exclusions= **/BuildProcess/**,**/DataDownward/**,**/Custom Scripts/**,**/Data/**,**/DataCorrection/**,**/DataModel/**,**/Security/**,**/*.css,**/*.html, **/*.xml,**/*.js,**/*.bin'
     sonar.cs.opencover.reportsPaths='$(Pipeline.Workspace)\a\**\SonarQube.opencover.xml'

- task: PowerShell@2
  displayName: 'Run Code coverage for DB'
  inputs:
    targetType: filePath
    filePath: './BuildProcess/SQLCover-0.5.0/src/SQLCover/releases/template/SQLCover.ps1'
    arguments: '-coverDllPath $(SQLCoverDllFullPath)  -connectionString $(connectionString) -databaseName "dbname" -query "EXEC tSQLt.RunAll" -PublishPath $(PublishPath)'

- powershell: |
   # PowerShell Script: Prepare OpenCover for SonarCloud
   
   $inputPath = "$(Pipeline.Workspace)\s\BuildProcess\SQLCover-0.5.0\src\SQLCover\releases\template\Coverage.opencoverxml"
   $outputPath = "$(Pipeline.Workspace)\a\SonarQube.opencover.xml"
   
   Write-Host "Checking if input coverage file exists..."
   
   if (Test-Path $inputPath) {
       try {
           [xml]$xml = Get-Content $inputPath
   
           # Optional: validate root tag
           if ($xml.DocumentElement.Name -ne "CoverageSession") {
               Write-Warning "Unexpected root node: $($xml.DocumentElement.Name)"
           }
   
           # Optional cleanup or modifications here (currently none)
   
           # Save as new file (Sonar expects a clean OpenCover XML)
           $xml.Save($outputPath)
           Write-Host "✅ Coverage file prepared: $outputPath"
       }
       catch {
           Write-Error "❌ Failed to parse coverage XML: $_"
       }
   } else {
       Write-Error "❌ Coverage file not found: $inputPath"
   }
   
   
  displayName: 'PowerShell Script'

- task: SonarSource.sonarcloud.ce096e50-6155-4de8-8800-4221aaeed4a1.SonarCloudAnalyze@3
  displayName: 'Run Code Analysis'
  inputs:
    jdkversion: 'JAVA_HOME'

- task: PublishCodeCoverageResults@2
  displayName: 'Publish code coverage results'
  inputs:
    summaryFileLocation: '$(Pipeline.Workspace)\s\BuildProcess\SQLCover-0.5.0\src\SQLCover\releases\template\Coverage.opencoverxml'
    pathToSources: '$(Pipeline.Workspace)\s\BuildProcess\SQLCover-0.5.0\src\SQLCover\releases\template\Coverage.opencoverxml'

- task: SonarSource.sonarcloud.38b27399-a642-40af-bb7d-9971f69712e8.SonarCloudPublish@3
  displayName: 'Publish Quality Gate Result'

Hi,

Welcome to the community!

Sorry, but we simply don’t support coverage for T-SQL.

 
Ann

Hi

I have the report generated already using a PowerShell script, just need to publish the results in the sonar cloud dashboard.
Is publishing the results is also not supported currently in sonarcloud ?

Hi,

Yes, that’s correct. We don’t import coverage results for T-SQL.

 
Ann