[Bitbucket Monorepo] Not showing widget statistics on PR after analysis completion

Issue:

I have setup Monorepo projects (backend and frontend microservice folders on Bitbucket) in my Sonar Cloud organisation. I can see that the widget is working as expected on Bitbucket when I view my repo and can visibly see the statistics for my monorepo projects both frontend and backend.

However, when I raise a PR, the PR decorations does not show the Sonar Cloud widget with the PR statistics as it should be. I keep getting “Not analyzed on SonarCloud yet…” even though it has been analysed on Sonar Cloud (https://sonarcloud.io/dashboard?id=jeiman-SampleRepo-ms-typescript-backend&pullRequest=4)

image

I am unsure how to fix this as it should work automatically. If you require further details, please let me know, I will update my discussion.

Please advise.

Thank you.


UPDATE:
Would this be the cause of the issue that I am facing? Previously this option was disabled, however it does state that it only works for Azure DevOps PRs for monorepos?

image

Welcome to the community!

I looked at your repo and setup (thanks for the links and details, very useful!). I confirm that your expectation is correct, on the PR you should see two widgets (for frontend and backend), just like on the main branch, and it’s not happening for some reason. So indeed something’s wrong.

The toggle you mentioned in your UPDATE is not an issue, that’s for Azure only. It’s not clear to me what is wrong, I need more time to investigate, and possibly help from my colleagues on Monday. So please stay tuned, keep the PR, the repo, and your setup there so that we can investigate, and I’ll get back to you next week.

Hi Janos,

No problem. Noted on this.

Thank you very much for looking into this matter for me. I really appreciate it.

I will look forward to your reply.

Ok, so by the time I got a chance to take a closer look at the problem, it seems to be gone now: the 2 widgets are correctly displayed on your PR now. We haven’t changed anything related at our side. Have you changed anything? Do you have another PR with the issue?

I will continue internal discussions to see if this is a known bug.

Hi @janos , yes I did check it 2 days ago. I can see the widgets showing, however, on our private organisation projects, the widgets are not showing. Is this issue related to Bitbucket Cloud and Sonar Cloud?

The pipeline and sonar cloud setup is similar, however, the repos and projects on Sonar Cloud are private.

From my end, I did not change anything. the only thing I changed was the formatting of my pipeline YAML (you can see from my PR commit history), which I doubt would’ve been the cause for the issue to be fixed, correct?

Any other ideas on how to make it work on my private organisation?

Please advise.

Hi @janos , curious to know if when we create a our monorepo projects, do we need to follow the standards mention in the UI. For example, if my organisation name is jeiman and my repo name is sampleRepo, do I need to follow the pre-filled project names defined by the UI? A photo example below:

Not sure if this is causing an issue for the widget to show the statistics on our PR in our org.

Looking at the documentation, it mentions the following:

We recommend using a pattern that includes your organization name, the SonarCloud project name and an internal reference to the project within the monorepo (for example: myorg_myproject_frontend ).

However, we have our own standard naming convention as part of our company policy that we need to comply with.

Just trying to rule out these anomalies.

Please advise.

Some additional findings on our private Bitbucket organisation repo:

It hit a 404/401 on our https://api.bitbucket.io/addons/sonarcloud/picklesauctions/repositories/uuid/pullrequests/111/code_quality

404:

CleanShot 2021-08-05 at 12.59.05

However, my PR on my private repo is active.

It can’t seem to find our repo UUID in relation to the code quality?

401:


Another finding:

Do I need to enable this for all of my projects? Could this be the one causing the PR widgets to not appear?

Nope, you don’t need to. The formatting of these names that you can freely enter on the UI cannot cause this issue.

That depends on how you created your project on SonarCloud. If you created the same way as you did the public project in your first post, then setting is not used (and not useful).

There is an important difference between the widget showing “Not analyzed on SonarCloud yet…”, as in your first post, and not having a widget at all. Basically if you have the widget at all, that’s good, because it shows that the binding to SonarCloud is correct. Another indicator of correct binding is seeing the Code Reports box on the right. Can you please confirm? At this point, I’m not sure if the issue with your private projects is the same as with the public one.

At least in the case of the public project, I suspect that this was probably happening when the widget content was missing. I did not have time to investigate further, I’m trying to make time soon.

If you configured the private repo the same way as the public one, and the symptoms are the same (widget is there but empty), then since the problem resolved by itself there without a change in configuration, you could try to trigger a new analysis of the main branch and then the PR, by pushing a commit to each. That’s really a shot in the dark though. Or in the worst case, and if it’s possible for you, you could try to reimport the project, in monorepo setup, as I suppose you did the public project. Or you could wait until I find and understand the bug at our side.

Hi @janos

Yes, the integration between Sonar Cloud and Bitbucket Cloud is working as expected. The widget is showing up on our repo page, showcasing all of our monorepo projects. SC analysis is working well as expected.

Only problem is with the PRs. The widget is enabled on the PR, however, it keeps showing “Not analyzed on SonarCloud yet…” on every PR raised (similar to my first post).

Right so for the public repo, I followed the naming convention as pre-filled by the UI for the monorepo project creation and enabled that PR provider option to point to BB cloud.

However, on our private organisation repo, we followed our own naming convention for the monorepo project creation. So we’re unsure if we need to enable that or not. However, you did mention that this will not cause the issue that we’re facing.

Not a problem. Please do investigate it from your end. If you can get back to us sooner, we would highly appreciate it. As I mention above, it keeps showing "Pull Request not found", so could be something from Sonar Cloud’s end that it is not linking the PRs correctly to the Sonar Cloud project. However, I can see the PR analysis on Sonar Cloud.

Hopefully we can resolve this soon. Thank you again for assisting us.

Following your own naming convention is totally fine. This is not the cause of the issue.

The fact that analysis is working and that you see the Code Reports box on the right indicates something’s wrong at our side. I’ll try to get back to you soon.

Do you have any more information about this issue?

I’m facing the same and I assumed it was an issue in my setup. Unfortunately, I’ve only got private repositories so I can’t share any further details.

As an aside, I’ve got a mix of mono-repo’s and project-repo’s. The widget populates successfully for the project-repo’s but not for the mono-repo.