Create projects which are bound to gitlab through the web api

We have Gitlab SAAS and Sonarcloud as part of our delivery pipeline.

By manual onboarding projects through the GUI the project is bound to Gitlab and therefor has some benefits.

Our delivery pipeline gitops solution does an automated creation of all gitlab repo’s including configuration for CD (Argo) etc. We also started creating our Sonarcloud projects through the web API

https://sonarcloud.io/web_api/api/projects?deprecated=false

However we noticed that the created projects through the WEB api are not bounded to Gitlab and there is no parameter to fix that.

The Sonarcloud GUI uses a different API it seems which is based on the unique Gitlab project ID as key:

print(‘Adding project with Python script on a very ugly ugly manner:’)
url = ‘https://sonarcloud.io/api/alm_integration/provision_projects
payload = ‘installationKeys=XXXXXXXX&organization=YYYYYY’
headers = {‘Content-Type’: ‘application/x-www-form-urlencoded’, ‘Authorization’: ‘Bearer {}’.format(sonartoken)}
res = requests.post(url, data=payload, headers=headers)

Would it be possible to extend the project WEB API with functionality to support the alm_integration/provision_projects way of working ? It does not seem so complex since the information is there ?

Hello @jvzoggel ,

A more automated way of onboarding new bound projects is definitely something that we are thinking about. You can follow this topic on the following roadmap card: https://portal.productboard.com/sonarsource/1-sonarcloud/c/51-automatic-provisioning-of-bound-projects .

We are also planning to add the ability to bind your project to a GitLab repository after it has been already created. Unfortunately, I don’t have an ETA, but we would love to have this in the short to medium term.

Could you share the number of projects you are creating per week or month?

Hi @Martin_Bednorz

Thanks for sharing the roadmap card. This card seems indeed exactly what I refer to.

Answering your question (or at least trying): * DevOps teams can create new projects depending on business needs, no general numbere here, but let’s say 25-50 new projects a month

However in the next years we will be migrating from external system integrators to our own internal IT Platform including redeveloping monoliths into smaller microservice architecture so this will result in more projects in our Gitlab SAAS and Sonarcloud instead of the external system integrator delivery pipeline tools. Additionally we are currently onboarding teams one-by-one from the initial SonarQube (EC2 AWS) to Sonarcloud which results in large amounts of projects to be created during the migration.

When moving our first team this resulted in 70 new projects. This is very frustrating doing it manual so we used the WEB APIs to create the project, set the permission template, set tags, etc.

1 Like

Thank you for the great insights! I’ve logged this internally and will update the thread once we have any news to share.

1 Like