SonarCloud Not Finding lcov.info Coverage Files

Environment

  • SonarCloud (cloud-hosted version)
  • Scanner: sonarsource/sonarcloud-scan:3.1.0 (via Bitbucket Pipelines)
  • Project Type: JavaScript/TypeScript

SonarCloud analysis is not detecting LCOV coverage reports despite tests running successfully with coverage generation.

19:24:53.563 DEBUG Property sonar.javascript.lcov.reportPaths is used.
19:24:53.563 DEBUG Using 'automate-api/coverage/lcov.info' to resolve LCOV files
19:24:53.586 INFO  No LCOV files were found using automate-api/coverage/lcov.info
19:24:53.586 DEBUG Using 'automate-ui/coverage/lcov.info' to resolve LCOV files
19:24:53.604 INFO  No LCOV files were found using automate-ui/coverage/lcov.info
19:24:53.605 WARN  No coverage information will be saved because all LCOV files cannot be found.

What I’ve Tried

  1. Configured sonar.javascript.lcov.reportPaths=automate-api/coverage/lcov.info in both sonar-project.properties and EXTRA_ARGS
  2. Verified tests run with --coverage flag
Pipeline file
definitions:
  services:
    docker:
      memory: 3072
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &sonarcloud-scan
        name: SonarCloud Scan
        caches:
          - sonar
        size: 2x
        script:
          - pipe: sonarsource/sonarcloud-scan:3.1.0
            variables:
              SONAR_TOKEN: $SONAR_TOKEN
              SONAR_PROJECT_KEY: $SONAR_PROJECT_KEY
              EXTRA_ARGS: '-Dsonar.typescript.tsconfigPath=tsconfig.sonar.json -Dsonar.javascript.lcov.reportPaths=automate-api/coverage/lcov.info,automate-ui/coverage/lcov.info -Dsonar.exclusions=**/*.test.ts,**/node_modules/**,**/dist/**,**/*.spec.ts -X'
              SONAR_SCANNER_OPTS: "-Xmx512m"

    - step: &quality-gate-check
        name: SonarCloud Quality Gate Check
        caches:
          - sonar
        size: 2x
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.2.0
            variables:
              SONAR_TOKEN: $SONAR_TOKEN
              SONAR_QUALITY_GATE_TIMEOUT: '300'
pipelines:
  default:
    - step:
        name: Test & Build
        image: node@sha256:e18f74fc454fddd8bf66f5c632dfc78a32d8c2737d1ba4e028ee60cfc6f95a9b
        caches:
          - node
        script:
          - npm ci
          - npm audit --audit-level=high --omit=dev
          - cd automate-api
          - npm run test -- --coverage
          - cd ..
        artifacts:
          - automate-api/coverage/**
    - step:
        name: Debug Coverage Files
        script:
          - echo "Checking coverage files..."
          - ls -la automate-api/coverage/
          - echo "File contents (first 10 lines):"
          - head -n 10 automate-api/coverage/lcov.info
          - echo "SonarCloud will look for files at:"
          - echo "automate-api/coverage/lcov.info"
    - step: *sonarcloud-scan
    - step: *quality-gate-check

Hi,

Can you check the workspace to verify the path to the LCov report?

Assuming the report does exist, then this is likely just a problem with the path analysis sees versus the one you’ve configured.

 
Ann