GitLab integration - Sonar alm_integration/list_repositories return HTTP 504

Hi,

I have configured the GitLab integration in Sonarqube Cloud. I have the “Team” plan. All projects are private.

Currently I can not create projects in Sonar, because no GitLab repositories can be found during the creation process. It was working for months and stopped working in the last weeks.

When I go to https://sonarcloud.io/projects/create I see after a few seconds:

No repositories found for this organization.
The request cannot be processed. Try again later.

In the Browser console output I see:

GET https://sonarcloud.io/api/alm_integration/list_repositories?organization=<MY_ORG_NAME> 504 (Gateway Timeout)

The GitLab integration / Organization Bindung under https://sonarcloud.io/organizations/<MY_ORG_NAME>/edit?category=binding reports “Personal access token: Valid”. And I can see API access from Sonarqube Cloud to GitLab by this token. Using a new token does not change anything.

What might be the problem?

Hey @chris41,

I can see in the logs which URL is being queried from GitLab that’s failing and causing this issue. I’m not sure it should be failing this way—something for the devs to investigate later—but I’ll send you the URL via PM. Could you check if you’re able to access it yourself while logged into GitLab?

1 Like

I have good news, as well as some less good news.

  • The good news: There’s an active sprint addressing this problem. While GitLab isn’t included in the current sprint’s scope, it will be covered in the upcoming one.
  • The less good news: At the moment, there isn’t an amazingly great workaround. Project import doesn’t work and binding after project creation in the UI also requires the repositories to be listed.

However, what you can do is manually create the project, then use the Web API to bind it. This involves sending a POST request to https://api.sonarcloud.io/dop-translation/project-bindings with a payload like the following:

{
  "projectId": "AZX8FyZAhfe4TD4HrpAU",
  "repositoryId": "54355206"
}
  • The projectId is found in the id field from https://sonarcloud.io/api/navigation/component?component=PROJECT_KEY.
  • The repositoryId is your project’s GitLab repository ID (visible in your GitLab project page).

The curl request would look like this:

curl -X POST "https://api.sonarcloud.io/dop-translation/project-bindings" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_SONARCLOUD_TOKEN" \
  -d '{
    "projectId": "PROJECT_ID",
    "repositoryId": "REPO_ID"
  }'
1 Like

Our team would like to know, @chris41 – about how many repos are in your organization, all sub-groups considered? Typically this only impacts users with a huge number of repos.

Thanks Colin for looking into it and the explanation. Sounds good.

We have approx. 5630 repos in this GitLab namespace.

1 Like

The manual creation of a project and binding to a GitLab project works for us. My team tested it.

1 Like