Quality Gate one 2nd analysis step


I want to use bitbucket pipelines and sonar to analyze my code. In my bibucket pipelines there are 2 analysis steps, the first one runs fine, I can see every results and analysis, but in the second step - which runs only on the main branch – the build in sonar quality gate doesn’t work.
If I redefine the quality gate, where I selected line coverage and code duplication it is calculated successfully. What is the problem with my setup?

This is my butbucket pipelines:

image: python:3.8

  depth: full              # SonarCloud scanner needs the full history to assign issues properly

      memory: 3000         # if you got an EOF file error, it can be caused by the

    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
          - docker # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
          - sonar
          # create environment
          - python3 -m venv env
          - source env/bin/activate
          - apt-get update &&  apt-get install -y python3 default-jre
          - pip install pytest pytest-cov -r requirements.txt
          - pytest --cov=src  --cov-report xml:coverage-reports/coverage-all.xml
          - pipe: sonarsource/sonarcloud-scan:1.2.1
              EXTRA_ARGS: "-Dsonar.sources=src"
              DEBUG: 'false'

    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

    - step: *build-test-sonarcloud
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

Welcome to the community!

I assume you’re talking about the step using the sonarcloud-quality-gate. Can you please clarify what “doesn’t work”? Does the pipe execution fail on Bitbucket? The last couple of lines with the failure message would be useful here.

Can you please clarify what exactly you did here?


without the quality gate-step, the bitbucket pipelines are running fine, every value calculated fine.

The built-in quality gate fails with the following message (below):

if I removed the built-in quality gate setup and made a test one that contains only the line coverage and the duplicated lines measures, it worked fine. I played with it and I found that only these 2 measures are working for me fine.

Is this Quality gate really supports Python projects?


Unable to find image 'sonarsource/sonarcloud-quality-gate:0.1.4' locally
0.1.4: Pulling from sonarsource/sonarcloud-quality-gate
d121f8d1c412: Pulling fs layer
ca572574cc82: Pulling fs layer
2bec6349c99d: Pulling fs layer
087ac0b72728: Pulling fs layer
6ca52d7c92b3: Pulling fs layer
f8f3658cfe37: Pulling fs layer
44dfc5bf09c4: Pulling fs layer
4cd0692f4960: Pulling fs layer
44dfc5bf09c4: Waiting
087ac0b72728: Waiting
4cd0692f4960: Waiting
6ca52d7c92b3: Waiting
f8f3658cfe37: Waiting
ca572574cc82: Verifying Checksum
ca572574cc82: Download complete
2bec6349c99d: Verifying Checksum
2bec6349c99d: Download complete
087ac0b72728: Verifying Checksum
087ac0b72728: Download complete
6ca52d7c92b3: Verifying Checksum
6ca52d7c92b3: Download complete
d121f8d1c412: Verifying Checksum
d121f8d1c412: Download complete
f8f3658cfe37: Download complete
44dfc5bf09c4: Verifying Checksum
44dfc5bf09c4: Download complete
4cd0692f4960: Verifying Checksum
4cd0692f4960: Download complete
d121f8d1c412: Pull complete
ca572574cc82: Pull complete
2bec6349c99d: Pull complete
087ac0b72728: Pull complete
6ca52d7c92b3: Pull complete
f8f3658cfe37: Pull complete
44dfc5bf09c4: Pull complete
4cd0692f4960: Pull complete
Digest: sha256:fefdf81312845d1773ec5dbb285f1628025f1496bda7a92e1d9f5f9994999a96
Status: Downloaded newer image for sonarsource/sonarcloud-quality-gate:0.1.4
✖ Quality gate has not been computed for project.

This usually happens when the New Code Period is not defined for a project, which prevents computing the quality gate. When this is the case, the project front page has this:

If this is your case, you can resolve it by clicking on Set New Code definition, and choosing one of the options. Then the next run of the pipe should not get the above error.

I was not able to reproduce this scenario: when new code period is defined, the pipe works fine with a Python project and using the default quality gate. When the new code period is not defined, I always get the error about quality gate not computed (correctly), regardless of quality gate (tested with a single condition on duplications).

Please let me know if you really have new code period defined, and still getting the failure!


Hello János,

These are my screenshots from my setup, I think I set what you mentioned, it shows my ‘test’ setup, which works, but if I check the other definitions they didn’t work for me. The other values calculated fine I’m not calculating the quality gate in the development branch.

Helló Tamás :wink:

And if you change the quality gate of this project to use Sonar Way, and re-run the pipe, then:

  • What is the state of the quality gate shown on SonarCloud?
  • What is the result of the sonarcloud-quality-gate pipe? (Failure with :heavy_multiplication_x: Quality gate has not been computed for project.” would really surprise me…)

Wow that’s new. The result of the pipe is accurate: the quality gate was not computed. The scenario is unexpected, since the quality gate must always be computed when the new code period is defined, which is implied by your previous screenshot.

I will investigate deeper to understand what’s going on here, and get back to you.

Looking at the metadata of the project, the New Code period is not defined. Although I still don’t understand how it was possible to get Quality Gate = Failed status in a previous analysis, it’s clear that an administrator should define the New Code, as the yellow box in your screenshot suggests. Once that’s done, the Not computed state should not happen again.

Please give that a try, and let us know if there are still issues.

Thanks, János, this solved the issue.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.