Link Projects To Gitlab When Creating Via API

We are moving to SonarCloud from on-premise SonarCloud and use Gitlab as our SCM and CI platform.

Ideally we want would like to add projects to SonarCloud from the CI pipeline rather than import them manually from the WebUI. We can do this successfully using the api/projects/create API call which works well for adding the project.

Analysis works. We see PRs, MRs in Gitlab speak, and default branch analysis. What we don’t get is PR annotation within Gitlab.

This appears to be because, although the account is linked to Gitlab, the project itself is not. There doesn’t seem to be a parameter in the API call to be able to do this, nor is there another API call to link the project.

Is there anyway for us to create linked projects using the API, perhaps with a hidden parameter, or will we have to add each project manually?

I would suggest voting on this item: Automatic Provisioning of sound Projects

Otherwise, you might be able to sort out what’s happening via API calls using this method:

https://community.sonarsource.com/t/how-to-reverse-engineer-the-sonar-web-api/66810/4

Thanks for this Colin. I’ve voted on the item.

I’ve already done one reverse engineering of the API to add members to the organisation. I had hoped I wouldn’t need to do another.