Reports empty or not being uploaded to Sonarcloud after running in Bitbucket pipelines

Hi there,

I just added the latest version of sonarcloud-scan to our project bitbucket-pipelines.yaml Everything looks to be working just find during the build, no errors but once we get the link to view the results, there is nothing there. Example: https://sonarcloud.io/dashboard?id=zlapps_todobot-api&branch=add-sonar-code-inspection&resolved=false

  • We installed SonarCloud app in our Bitbucket account
  • I can see our repositories in our SonarCloud account
  • When Pipelines run, I can see over 700 files indexed and the different sensors running

Full log here https://bitbucket.org/snippets/zlapps/LjzKbk

Relevant part of our bitbucket-pipelines.yaml

  step:
    name: Run tests
    caches:
      - node
      - sonar
    services:
      - mongo
      - redis
    script:
      - export DB_TEST_URL=mongodb://localhost:27017/todobot-test
      - export REDIS_URL=redis://localhost:6379
      - npm install
      - npm test
      - pipe: sonarsource/sonarcloud-scan:1.0.0
        variables:
          SONAR_TOKEN: ${SONAR_TOKEN}
          EXTRA_ARGS: '-Dsonar.sources=src -Dsonar.tests=test'
          DEBUG: 'true'

SonarCloud Project Key: zlapps_todobot-api

I hope you can help us :slight_smile:

Hi,

Can you check that the background task on SonarCloud has been successfully executed without any warnings ?

You can find them in “Administration” -> “Background tasks” menu of your project.

Thanks.

Mickaël

Hi,

No errors there. Here is a screenshot

And here is the scanner context from the latest job if helps https://bitbucket.org/snippets/zlapps/eA7e4z

Thanks

Did you have a chance to look into this? thanks

Hi Guillermo,

Are you analyzing the default branch of the repository ?

Thanks.

Mickaël

Hi Mickael,

No, all screenshots and logs I shared was running the analysis in a feature branch (short live branch) In the screenshot above that would be “add-sonar-code-inspection” That is a feature branch out of the default branch. Bitbucket pipelines run just fine, and the logs seems to indicate that also Sonar is doing its job correctly, so I am not sure where is the data getting lost.
Thanks

Yes but if you haven’t yet analyzed the default branch of the repository, that could be the reason why it’s not displaying anything.

Mickael

Hi,

Further question : Do you have something in the dropdown when clicking on master on the top of the SonarCloud page ?

If yes, when clicking on the analyzed branch, is there any warning displayed on the top right corner ?

Thank you.

Hi,

Thanks for the help. So when we merged the branch with the bitbucket-pipeline changes into our main branch, we were able to see the report in SonarCloud, this is working just fine.

Unfortunately, we created a new feature branch and we are still not seeing any results in SonarCloud.

There are no issues with the branch either and if you look into our account, the main branch “dev” has the latest results.

Any ideas how we can get a feature branch to work?

By feature branch, you mean the ones we call ‘long-living’ branches in our documentation ?

If yes, by default, the name of the branch should match this pattern : (branch|release)-.* which is editable in the top left corner of the screen, on the “Administration -> Branches” menu.

Mickaël

By feature branch I mean a branch that will only exist during the development of a particular feature in the repository and is the one used to create a pull request against the main branch. That branch will only exist for a few days.

Right now, when we push any branch to Bitbucket the SonarCloud pipe runs and it looks like the system is picking it up

But it just dones’t show any code when you click on any of those branches. (TGVT6-add-coverage-and-test-reports)

I’m facing the same issue when scanning a short lived branch like feature/some-branch.
We are using jenkins pipeline to automate scanning every time a commit is made on bitbucked.
The analysis seems to complete OK but the results are empty, and I know there should be some code smells.

The strange thing is that when I manually run the scan on my laptop and passing the exact same arguments used in jenkins pipeline the results are uploaded successfully and reported on the project

Any update?

Hi Guillermo,

So i just checked on my side and even though a background task has the status of “passed”, there could be a warning that has occurred. You can check with the first screenshot you sent, click on the wheel and see if “Show warnings” contextual option is displayed or not. By the things you said, i’m very not sure if there was one or not. Could you check that ?

Thanks.

@Artemis_Braja as you can see, there’s a warning on the right of you screenshot? Could you please check it ? If it’s not related to pull request, i suggest you to open a new thread. Thanks.