How to use organization for both Bitbucket & Github?

Hi,

I have trouble setting up SonarCloud pull request decoration.

Our primary platform is Bitbucket Cloud, where we use Bitbucket Pipelines to manage our builds and also trigger Sonarcloud analyses. This works fine so far.

However, our open source projects reside on GitHub, and builds run via travis-ci.org. When setting up the SonarCloud app on GitHub, I chose “import from bitbucket”. Then, over at Bitbucket, I chose the correct Bitbucket team, and am redirected back to SonarCloud. There, I get this error message:

Your organization incub8 Software Labs is already bound to the SonarCloud organization incub8. Try again and choose a different organization.

Does this mean I have to maintain two separate SonarCloud organizations (rules, members, permissions …), one for GitHub, one for Bitbucket? Or worse, is our use case not supported by SonarCloud at all?

Best regards,
Jens

Hi Jens,

If I understand correctly your use case, you have some projects hosted and run on BitBucketCloud and you have different projects hosted on Github. Is that correct ?

From the error message, you already have an organization on SonarCloud incub8, how did you set up this organization, is it bound to BBC team or GH org ?

Can you clarify why you would select a BitBucket team to import GitHub projects?

Thanks

Hi Aurélie,

thanks for looking into our case!

you have some projects hosted and run on BitBucketCloud and you have different projects hosted on Github. Is that correct ?

Exactly.

From the error message, you already have an organization on SonarCloud incub8 , how did you set up this organization, is it bound to BBC team or GH org ?

It is bound to a Bitbucket Cloud team.

When setting up the SonarCloud app on GitHub, I chose “import from bitbucket”

Can you clarify why you would select a BitBucket team to import GitHub projects?

I think when the configuration process of the SonarCloud GitHub app asked me for a SonarCloud organization, I had no other option (other than creating a new organization), or I had the option of “use existing organization” but it did not work. To be honest, I no longer remember the exact steps I took, sorry. It seems I described the process in a misleading way; when I’m back in the office, I will try setting it up again, writing down all the details this time.

However, I would appreciate it if you could already state your expectation: should it be possible to configure the GitHub SonarCloud app to work with a SonarCloud organization that was already bound to a Bitbucket Cloud team?

Best regards,
Jens

Your organization incub8 Software Labs is already bound to the SonarCloud organization incub8 . Try again and choose a different organization.

P.S.: Another detail that may not be obvious: “incub8 Software Labs” is the name of our team on Bitbucket Cloud. That platform, unlike GitHub, does not use the term “organization”. (Maybe it did at some point, I don’t know.)

Of course this naming inconsistency in the SonarCloud error message does not explain our problem, but I thought I’d clarify this. Maybe you can change the error message and other UI texts relating to Bitbucket Cloud accordingly.

Hi Jens,

Unfortunately, it’s not possible. One SonarCloud organization is either bound to a BitBucket team or a GitHub org, to provide the best integration depending on the dev platform (allowing PR decoration, with GitHub you can synchronize your members for ex.).

To bind your GitHub organization, you will have to connect on SonarCloud with your GitHub account, and not with your BitBucket account. SonarCloud will find directly your GH org and projects that you can bind to SonarCloud.

However, could you explain what is your use case exactly, what is sharing between GitHub and BitbucketCloud? That would help us to see if there’s anything we can improve.

Hope it helps,

Cheers

Hi Aurélie,

sure! As I mentioned in the initial post, Bitbucket Cloud is our primary platform, which means all our closed-source code resides there. Our GitHub projects belong to the GitHub organization “mizool”. Below, I will assume we would create a corresponding SonarCloud organization with the same name.

(Note that currently, only one mizool project is analysed by SonarCloud, but we will definitely add more once we have successfully set up the GitHub SonarCloud app.)

So why use GitHub at all, and why not move over completely? When we started open sourcing some of our code, we decided we should do that where the majority of open source developers are active. But moving our closed-source code to GitHub as well would not only mean losing Bitbucket Pipelines and the tight integration with Atlassian Jira and Atlassian Confluence, it would also cause a large amount of migration work and increase running costs.

Here are a few aspects that are currently shared and some thoughts what to do about it.

  • Our quality profile incub8 way is used both for our Bitbucket Cloud projects and the GitHub projects, and we would like to keep it that way.
    • Having to maintain this manually in two organizations or by exporting from one and importing to the other is too cumbersome as the profile contains 473 rules. The comparison feature (very useful, by the way!) says there are 84 rules only in incub8 way, 5 rules are only in Sonar way, and 3 rules have a different configuration.
    • Possible solution: building on top of my previous suggestion to allow making quality profiles public, SonarCloud could allow an organization (mizool) to reference a public quality profile of another organization (incub8).
  • Our quality gate incub8 way is currently used only for our Bitbucket Cloud projects. The GitHub projects use a separate gate, mizool way. We aim to unify them.
    • As setting up a quality gate is not much work, we could live with a manual process.
  • Employees logged in to SonarCloud with their Bitbucket Cloud users can interact with the GitHub projects (comment/close issues, change configuration).
    • Setting up the mizool organization using a GitHub user is okay.
    • However, it would be a pain if people needed to be logged in to SonarCloud via a GitHub user to interact with the projects in the mizool SonarCloud organization.
      • Background: A huge advantage of logging in via BitBucket Cloud is single sign on: Bitbucket Cloud user ➞ Atlassian ID ➞ G Suite.
    • Possible solutions:
      • I think it would be acceptable if we had to manually add the Bitbucket Cloud users as members of the mizool SonarCloud organization.
      • That said, it would be great if people who have several SonarCloud accounts could link them, and organizations trusting one would automatically trust the other.
  • Billing
    • Only our Bitbucket Cloud projects are private, the GitHub projects are public. Having two separate organizations would mean that incub8 is on the paid plan and mizool is on the free plan. That’s fine.

I would have to think a bit about how setting up and maintaining permissions and notifications would work in a two-organization world.

Hope this gives you some insight! Tell me if I can clarify things or help in another way.

Best regards,
Jens

2 Likes

Hi Jens,

Thanks a lot for taking the time to detail your use case :slight_smile:
Yes it gives insights and we will discuss this internally.

I don’t expect that we do something in this regards in the short term, in the meantime don’t hesitate to ask for help if needed.

Cheers,

1 Like