SonarCloud analysis does not works for Python project in BitbucketPipeline

Template for a good new topic, formatted with Markdown:

  • ALM used: Bitbucket Cloud
  • CI system used: Bitbucket Cloud
  • Scanner command used when applicable:
    - pipe: sonarsource/sonarcloud-scan:2.0.0
    - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
  • Languages of the repository: Python
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
INFO: 484/484 source files have been analyzed
INFO: The Python analyzer was able to leverage cached data from previous analyses for 0 out of 484 files. These files were not parsed.
INFO: Sensor Python Sensor [python] (done) | time=19791ms
INFO: Sensor Cobertura Sensor for Python coverage [python]
INFO: Python test coverage
INFO: Parsing report '/opt/atlassian/pipelines/agent/build/coverage-reports/coverage.xml'
WARN: Invalid directory path in 'source' element: /home/*company*
ERROR: Cannot resolve the file path '' of the coverage report, the file does not exist in all 'source'.
ERROR: Cannot resolve 577 file paths, ignoring coverage measures for those files

My step in bitbucket-pipelines looks like this:

    - step: &run-tests-sonarcloud
        name: Run tests
        size: 2x
          - docker # adds docker layer caching   # See
          - node
          - pip
          - docker-base
          - sonar
          - *load-docker-base-image-if-exists-in-cache
          - *bla-bla-bla*
          - *save-docker-base-image-if-missing-in-cache
          - mkdir coverage-reports
          - >-
            docker run
            -v $*bla-bla-bla*
          - >-
            docker run
            -v ${PWD}/coverage-reports:/coverage-reports
          - pipe: sonarsource/sonarcloud-scan:2.0.0
              DEBUG: 'false' #DEBUG
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.6
          - docker
  • Steps to reproduce: I am trying to launch Sonarcloud analysis for my project. But, it seems, that it does not work at all. I see 0 bugs, 0 code smells, 0 vulnerabilities, 0 security hotspots, and 0 coverage. From logs I can see, that Sonar is analyzing the code, and successfully send the results, but I can’t see anything in web Sonar. What am I doing wrong? :slight_smile:
    I’ve checked file, and it looks good:

My files structure on bitbucket instance looks like this:
In the . we have:

  • Potential workaround

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!


Welcome to the community!

The analysis log snippet you’ve provided shows a problem with your coverage reports which is unrelated to the number of issues detected.

If you check the Measures tab of the branch in question (main, I guess?), and expand “Size”, is Lines of Code a non-zero number?

And can you provide your full analysis log?


The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.