Pull request and new branch not showing in SonarCloud. Is it possible to show without a pipeline?

We just joined Sonarcloud and we are trying to set it up for one of our Python projects that we have on Bitbucket Cloud.

We were able to import the repository from Bitbucket Cloud correclty.

Then we were trying to configure the bitbucket-pipelines.yml file. But we did not sucess with that. All of our executions finished with any error (We tried different versions of the bitbucket-pipelines.yml with different configurations)

After several executions of the pipelines, we were able to see some info in the project section:
In the “Overview” tab, we see Quality Gate as not computed. We also see our First analysis in the “latest activity” section there, but just for the main branch.
(At this point we are not sure if this information was generated by the running of our pipeline, or but SonarCloud itself after importing the BitBucket Cloud repository)

Then we modified our code, fixing some of the bugs, code smells… and created a pull request.
We can see the pull request on BitBucket Cloud. (And the icon showing that the pipeline run failed at the top right corner.)
At this point we expected to see our pull request, and new branch also in the SonarCloud side. But we don’t.

  • Do we need our pipeline to finish correctly to be able to see our pull request on SonarCloud side?
  • Is it possible to see the same metrics that we see for the master branch, but for the new branch without running any pipeline? If yes, we would like to see any comparison between the two, to see how the bugs, code smells… improved.
    (For the moment we are just focused on these metrics, not on test coverage)

Hey there.

A pipeline is required. Automatic Analysis (such as is available for GitHub) is not available for Bitbucket Cloud, but it is something we are looking at. No information will be sent to SonarCloud without successful completion of the SonarCloud analysis pipe.

What are the errors you received, and what have been the various configurations of your bitbucket-pipelines.yml matching those errors?

Hi Colin.

Thanks a lot for your help and the explanation about the pipeline.

The different configurations that we tried are basically variations of the definitions->steps->script section.
Here our current bitbucket-pipelines.yml.
The result that we get when we run it is the following:
“Build, test and analyze on SonarCloud” → :heavy_check_mark: SonarCloud analysis was successful.
“Check the Quality Gate on SonarCloud” → :heavy_multiplication_x: Quality gate has not been computed for project.

image: python:3.5.2 # Choose an image matching your project needs

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

definitions:
  services:
    docker:
      memory: 3000
  caches:
    sonar: ~/.sonar/cache  # Caching SonarCloud artifacts will speed up your build
  steps:
    - step: &build-test-sonarcloud
        name: Build, test and analyze on SonarCloud
        caches:
          - pip           # See https://confluence.atlassian.com/bitbucket/caching-dependencies-895552876.html
          - sonar
        script:
          - # python3 -m venv env
          - # source env/bin/activate
          - # pip install pip==19.0.3
          - # cat pip-requirements.txt | grep --invert-match pkg-resources | xargs -n 1 pip install
          - # pip install pytest pytest-cov
          - pipe: sonarsource/sonarcloud-scan:1.2.1
    - step: &check-quality-gate-sonarcloud
        name: Check the Quality Gate on SonarCloud
        script:
          - pipe: sonarsource/sonarcloud-quality-gate:0.1.4

pipelines:                 # More info here: https://confluence.atlassian.com/bitbucket/configure-bitbucket-pipelines-yml-792298910.html
  branches:
    master:
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud
  pull-requests:
    '**':
      - step: *build-test-sonarcloud
      - step: *check-quality-gate-sonarcloud

Okay. Sounds good so far. When you click on the link at the end of Build, test and analyze on SonarCloud, what do you see?

INFO: ANALYSIS SUCCESSFUL, you can find the results at: https://sonarcloud.io/dashboard?id=example&pullRequest=2
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at https://sonarcloud.io/api/ce/task?id=AXjLu0oThhPfU3odwPb0
INFO: Analysis total time: 20.718 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 52.787s
INFO: Final Memory: 44M/147M
INFO: ------------------------------------------------------------------------

Hi Colin.

Your comment make me realize that bitbucket-pipelines.yml in the pull request was incorrect. (My last message was about master branch, not the pull request)
After updating it to the version in my previous message, I can see the pull request metrics on SonarCloud side. Thanks a lot!
Any idea how to solve the “Quality gate has not been computed for project” error?

The SonarCloud UI is pretty clear about this!