Quality Gate is not working as expected for Mono Repo PR in Bitbucket

Template for a good new topic, formatted with Markdown:

  • ALM used (Bitbucket Cloud)
  • CI system used (Bitbucket Cloud)
  • Scanner command used for Pull Request Pipelines
  • Languages of the repository: Javascript
  • Steps to reproduce
    • Have a mono repo configured in SonarCloud and multiple projects bound to the mono repos
    • In bitbucket, the mono repo includes the all projects
    • Apply quality gate feature for the mono repo in bitbucket pipeline
    • When an PR pipeline of the mono repo is completed in bitbucket pipeline, the pipeline does code analysis for some projects in the mono repos and are reported in PR analysis in SonarCloud, there are 1 project failed Quality Gate and reported in SonarCloud. However, in bitbucket PR, it is reported as Quality Gate passed, and was linked to the latest analysis result (which was passed)

Question: For Quality Gate and Bitbucket PR integration, could we support Quality Gate checks for all projects analyzed in mono repository?

Hey there.

I tried this out on my end and was able to get a PR with two Quality Gates reported on a PR after configuring my projects as a monorepo.

Have you checked that the appropriate SonarQube Cloud projects are bound to your repo? You can check this in your Bitbucket repository settings.

You’ll need to make sure that all of these projects have been analyzed in the context of your PR.

If you’re still stuck, I suggest sharing your full bitbucket-pipelines.yml file.

Hi @Colin ,
I could configure and got same result as you shared. However, it doesn’t meet my expectation. Here is the scenario:

  1. Have a mono repo having AppA and AppB
  2. In the PR pipeline of the mono repo, it has multiple apps that get analysis separately but still in same PR pipeline. In this case, they are AppA and AppB
  3. After the analysis has done in SonarCloud (AppA completed the analysis first then AppB did), I could see multiple PRs report for the apps: AppA and AppB: AppA failed the Quality Gate, AppB passed the Quality Gate in SonarCloud.
  4. However, in the Bitbucket PR of the mono repo, in Quality Gate build, it only displayed the last completed analysis at step 2 and the result. In this case, Quality Gate Build Result shown in the Bitbucket PR was green → I expected it should be failed because Quality Gate for AppA was failed.

Can you share a screenshot? I fear we aren’t speaking about the same thing and I’d like to make sure.

Hi @Colin ,
Here are the screenshots for the Quality Gate Result displayed in Bitbucket PR of our mono repo. In this case, we had 2 PRs analysis result, first one got failed and the other passed. The UI only linked to the passed one because it was completed after the failed one.


Note: I already configured and bound the 2 projects into the mono repository as you shared above for the configuration/binding.

I think the issue here might be that you’re providing the same project key to the scanner for each analysis. Could you share your Bitbucket Pipelines YML?

No, they are using different keys definitely. I already checked them. And in sonarcloud , I also saw 2 PRs for the 2 bound projects in sonarcloud. Could you share your check that show 2 different quality gate builds in your bitbucket PR that you shared above?

Hey @Adam_Tran

Indeed I do see the two different quality gates.

I would still be interested in seeing your Bitbucket Pipelines YML, especially the one checked into the branch you’re raising a PR on!

Hi @Colin ,
After checking again, I see our Bitbucket CICD pipeline working with mono repo well now.
Thank you for the supports!

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