Get Bitbucket project ID from SonarCloud API

Hi,

I added a project from Bitbucket and I’m wondering if there’s a way I can get his Bitbucket ID through the SonarCloud API. I need to merge data from Bitbucket and Sonar, but in order to do that I need a way to link them both.

The api/projects/search endpoint returns a project key of the shape: “organization_project-slug”, but that name does not always coincide with the name in Bitbucket. How do you maintain that reference internally?

Thanks in advance.

Hello Camilo and welcome to the community forum!

We currently don’t have any public API that allows to know that and we don’t expose publicly this binding between a repo and a project.

You could eventually rely on the api/navigation/component api, which is an internal api endpoint, so it’s subject to changes but has been pretty stable lately. In the response of this api you have the following data:

alm: {
  key: "bitbucketcloud",
  url: "https://bitbucket.org/sonargregaubert/test-visibility"
}

And in the url field here you can see the bitbucket repo slug. Note that this data will be present only if the project is bound to a Bitbucket repo.

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