How do I script linking a SonarCloud project to a Bitbucket Cloud repo

I already programmatically create new sonar projects with the REST API: https://sonarcloud.io/api/projects/create

Im setting all these values in the scanner command. everything works except it looks like I still have to link it to the BB repo to get the widget?

// sonar project key
/k:“mykey”

// project name- human readable project name that appears in the UI
/n:“myproject”

// scan version
/v:“myversion”

// sonarcloud token
/d:sonar.login=“mytoken”

// sonarcloud org
/o:“bitbucketTeam”

// coverage report
/d:sonar.cs.opencover.reportsPaths=opencover.xml"

// Bitbucket branch and PR
/d:sonar.pullrequest.branch=“mybranch”
/d:sonar.pullrequest.key=“myPRkey”

// PR decorator. So sonarqube can post build status to the PR in bitbucket
/d:sonar.pullrequest.provider=bitbucketcloud
/d:sonar.pullrequest.bitbucketcloud.repository=repo-UUID
/d:sonar.pullrequest.bitbucketcloud.owner=UUID

When i look at SonarCloud setting it says “To display the quality of your repository, you have to link it with a project analyzed on SonarCloud.”

I dont want to manually do that for every one of my repos especially because ive automated everything up to this point

Hi @red_888,

Welcome to our community!

For now it is not possible to script the link between a BitBucketCloud repo and a SonarCloud project.
We would like to provide the ability to onboard on SonarCloud via an API, but it will not be available in the short term.

Cheers,