Sonarqube 8.9 with monorepo

I’m using SonarQube Enterprise Edition Version 8.9.6 (build 50800) and I would like to use its mono repo capabilities. For git repository I’m using Bitbucket v7.6.7.
I have set up test repository with two projects folders and configure two separate projects in Sonar. Each project have PR decoration with mono repo checkbox like in docs Bitbucket Server Integration | SonarQube Docs. I have individual builds in TeamCity for each folder in bitbucket connected with sonar projects. When I’m creating PR I’m receiving reports with different id like com.sonarsource.sonarqube_ax_5jcwlypjykt0ochie and this is correct. But When I want to prevent merge docs says that I have to configure code insights but this configuration is for whole repo so when I configure two id’s and have PR for one of the projects I’m always have one report so I have merge warning like ‘Report with key ‘com.sonarsource.sonarqube_ax_5jcwlypjykt0ochie’ has not yet been created’ because this PR will never have this report. Is there any way to do this work for my case?

1 Like

Hey there.

There’s an assumption that a decoration for each project in the monorepo will be available, which won’t work if you are selectively building your projects based on the changes.

This is a common frustration with users of GitHub (no concept of “conditional” merge checks) and you may want to raise the same with Bitbucket.

I’ll pass your feedback along as it’s not the first report we’ve had of this. Unfortunately, it means you probably cannot conveniently implement a policy to block or allow the merge of the PR.

1 Like

Thanks for response. One of the soulution could be setting build status from sonar side just like TeamCity Commit Status Publisher | TeamCity On-Premises.

Is there any sonar API I can invoke to check status of quality gate so I could set build status myself? Or maybe it could be done from other side - execute some custom code after sonar finish (code similar to commit status publisher I mentioned)

Ok I found this Overview | SonarQube Docs so I can wait and for async I can use webhooks :slight_smile: