How to do Sonarcloud integration with bitbucket for microservices

Hi ,

How to do Sonarcloud integration with bitbucket for microservices. Where in our project we have used 5 languages (gradle, c#, go, c++). So please guide me how I will integrate sonarcloud for microservices, so that it will show quality analysis report for all microservices.

Hi @R_Venkatesh_Reddy,

Welcome to our community!

What are you referring to when you say “SonarCloud integration”? Are you referring to Pull Request decoration ?
If so, this is a use case that it’s not well supported for BitBucketCloud as for now, but it’s in our plans.

Would you mind sharing what CI do/will you use to launch the analyses?

Thanks.

Hi Aurelie,

I am using bitbucket pipeline for CI, where Sonarcloud we are suppose to use in our bitbucket YML and in our project we have used 5 languages.

I want through the documentation of sonarcloud where we have to give our repository URL. So my question is how I will setup Sonarcloud to read each directory of repository (which is small microservices) and should show the quality analysis in sonar dashboard?

Hi @R_Venkatesh_Reddy,

Can you clarify:

  • What buiding tool(s), and possibly what scanner do you use to build your repository, or your microservices?
  • Can you copy/paste here the content of your current YML file
  • What have you tried so far on SonarCloud and what is not working?

Thanks.

Hi Aurelie,

Sorry for the late reply.

  1. Build tool are :- gradle, make, msbuild
    I want all microservice should get scanned and show the analysis reports for all microservices.

  2. Below is sample of my yml.

pipelines:
branches:
develop:
-step:
name: Build, Test and Sonarcloud
script:
- cd folder1
- bash ./gradlew clean build
- cd …
-step:
name: Build, Test and Sonarcloud
script:
- cd folder2
- nugget restore file1.sln -NonInteractive
- Mono_IOMAP=case msbuild /t:Build /p: Configuration=“Release” /p:Platform=“Any CPU” /p:OutputPath="./bin/Release/" file1.sln
- cd …
-step:
name: Build, Test and Sonarcloud
script:
- cd folder3
- make
- cd …

  1. For these 3 build tool how I will use Sonarcloud in my repository. Please guide me.

Hi @R_Venkatesh_Reddy

The best solution would be, as we do not support yet “multi-build technologies analyses”, to create 1 SonarCloud project for each of those build tools, otherwise each analysis will overwrite the previous one.

Hi Mickael,

Is it possible to create multiple Sonar Projects (for different technologies) pointing to same Bitbucket Repository (Mono Repository).

We have a Mono Repository in Bitbucket with multiple microservices into separate folders (java, .net, C, GO, etc.). So we want to analyze this Bitbucket Mono repository with Sonarcloud.

Will sonar support Mono Repository in Bitbucket?

Hi,

Yes you can, the only thing is that you will not be able to have multiple Quality Gate widgets on the PR / repo page on Bitbucket, this is not currently supported.

Hi Mickael,

Will it show multiple Quality Gate in Sonarcloud dashboard?

Can you please refer some documents of sonar for Mono Repo support.

You will have as many Quality Gate as the number of projects you will setup. However they will not be grouped on SonarCloud, but displayed as currently, in each different project.

We support “mono-repo” for GitHub and Azure DevOps only for now, and this is only decorating Pull Request with multiple Quality Gate results.

You can read docs here : https://sonarcloud.io/documentation/analysis/setup-monorepo/
But again, this specific use case is not supported on Bitbucket yet :wink:

I found one link where this repo on GitHub shows how to use Sonarcloud webhooks to decorate PRs on Azure.
Link - https://github.com/izanbard/sonarhook

Is it possible same for bitbucket or else is there any other workaround to get multiple Quality Gate as for time being.

Except some fork somewhere, we don’t support this scenario yet, sorry !

Hi Mickaël,

Is supporting monorepos in Bitbucket Cloud on the roadmap and if yes is there any ETA for when this feature will be supported in Bitbucket cloud?

Thanks
Valery.

It’s something we have in mind but we don’t have any ETA to give you, mainly because it was not asked enough by our users/customers. I you want to give that a bit more traction, i suggest you to opened a new feature suggestion and ask for votes, we then may reconsider the priority of that feature.

Thanks !

Mickaël

Hi Mickael,

We have purchased licenses for sonarcloud. we have integrated bitbucket cloud repositories for sonarcloud. our bitbucket cloud has instance of mono repo. per documentation, sonarcloud only supports monorepo hosted on github.

for now we want to understand how we can scan mono repo hosted on bitbucket cloud (as best practice) till the time you add it as feature to support monorepo on bitbucket cloud.

Thank you in anticipation.

Amol