Bitbucket pipeline failed to execute successfully due to coverage report path

  • ALM used (Bitbucket Cloud)
  • CI system used (Bitbucket Cloud)
  • Pipeline created like:
image: atlassian/default-image:2

options:
  docker: true
  size: 2x
  
clone:
  depth: full

definitions:
  caches:
    sonar: ~/.sonar/cache
  steps:
    - step: &sonarcloudanalyze
        name: Analyze on SonarCloud
        caches:
          - sonar
        script:
          - pipe: sonarsource/sonarcloud-scan:1.3.0
            variables:
              SONAR_TOKEN: 'XXXXXXX'
              EXTRA_ARGS: -Dsonar.projectDescription=\"ABC" -Dsonar.eslint.reportPaths=\"SonarCloud/sonarqube-generic-coverage.xml\"
              SONAR_SCANNER_OPTS: -Xmx512m
              DEBUG: "false"
        size: 2x
        services:
          - docker
  services:
    docker:
      memory: 2048 

pipelines:
  branches:
    '*':
      - step: *sonarcloudanalyze```



  • Languages of the repository =Swift

  • Error observed is below:

INFO: Sensor Generic Coverage Report
INFO: Parsing /opt/atlassian/pipelines/agent/build/SonarCloud/sonarqube-generic-coverage.xml
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:26.622s
INFO: Final Memory: 101M/354M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
ERROR: Error during parsing of the generic coverage report '/opt/atlassian/pipelines/agent/build/SonarCloud/sonarqube-generic-coverage.xml'. Look at SonarQube documentation to know the expected XML format.
ERROR: Caused by: /opt/atlassian/pipelines/agent/build/SonarCloud/sonarqube-generic-coverage.xml (No such file or directory)
ERROR: 
ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.
✖ SonarCloud analysis failed. (exit code = 2)

Kindly guide me if i am missing anything while generating the pipeline.

Hi @MOODAZZ , welcome to the community forum.

It seems the coverage file does not exist when the scanner is executed.
In your pipeline file, I don’t see any other step before the sonarcloud-scan pipe, that could generate that coverage file.

Did you edit the file before posting it to remove the project build steps? If so, could you please post the full file? Could you also double check that the coverage file has been written where the scanner searches it?

Otherwise, you need to build your project before running the sonarcloud scan.

For example on that demo repository, you can see the npm run test... command, just before the sonarcloud-scan pipe. You can take inspiration from that example, replacing the NPM command but the one that fits your project.

Hi @Claire_Villard you pointed out right that i am not using any build steps before scan pipe, actually i am not able to find the command like npm run test for xcode/swift project.If you know that kindly guide me.

I’m very sorry, I’m not a Swift developer at all, I can only help you on the SonarCloud integration, not on the parts specific to the build of your project.
Maybe this sample repository could help, even if it is not integrated on Bitbucket pipelines?

Have you tried removing the sonar.eslint.reportPaths parameter, to remove the coverage part of the analysis, and get the benefits of the other parts of the analysis (code smells, bugs, security hotspots, …)?