SonarCloud - Swift Code Coverage Showing 0%

  • ALM used - Azure Devops
  • CI system used - Azure Devops and fastlane
  • Scanner command used when applicable - Pipeline tasks:
  1. task: SonarCloudPrepare@1
    inputs:
    SonarCloud: “SonarCloud”
    organization: -----------
    scannerMode: “CLI”
    configMode: “manual”
    cliProjectKey: ---------
    cliProjectName: ----------
    cliSources: “.”
    coverageReportPaths: sonarqube-generic-coverage.xml
    extraProperties: |
    sonar.c.file.suffixes=-
    sonar.cpp.file.suffixes=-
    sonar.objc.file.suffixes=-
  2. Run tests with fast lane**
  3. task: Bash@3
    displayName: “Sonar Code Coverage”
    inputs:
    targetType: inline
    script: ./xccov-to-sonarqube-generic.sh ./output/Logs/Test/*.xcresult/ > ./sonarqube-generic-coverage.xml
  4. task: SonarCloudAnalyze@1
  5. task: SonarCloudPublish@1
    inputs:
    pollingTimeoutSec: “300”
  • Languages of the repository - Swift
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
    The SonarCloud coverage report (sonarqube-generic-coverage.xml) is generated and it is populated as expected. However after publishing, it still shows 0% coverage for that analysis.

In the logs, I do see:
DEBUG: ‘Generic Coverage Report’ skipped because one of the required properties is missing
DEBUG: ‘Generic Test Executions Report’ skipped because one of the required properties is missing

  • Steps to reproduce
  • Potential workaround

Hey there.

coverageReportPaths is not a valid option for the task – you should pass sonar.coverageReportPaths to the extraProperties.

That fixed it.

Is there documentation for the azure pipeline tasks?

Hey @roanutil

You can find documentation for the SonarScanner for Azure DevOps here – although the YAML syntax is not precisely documented.