# Setting up GitLab integration at global level

This section explains how to set up GitLab and SonarQube Community Build for global integration. To perform this setup, you need the global Administer System permission in SonarQube Community Build.

{% hint style="info" %}
You can also check out this [video](https://www.youtube.com/watch?v=XX0ey4rRvms) on GitLab integration.
{% endhint %}

## Preparing the integration <a href="#preparing" id="preparing"></a>

<details>

<summary>Verifying the server base URL</summary>

You must configure your SonarQube Server base URL in SonarQube Server, otherwise, integration features will not work correctly. See [server-base-url](https://docs.sonarsource.com/sonarqube-community-build/instance-administration/server-base-url "mention").

</details>

<details>

<summary>Generating a token</summary>

You must provide a GitLab access token that will be used by SonarQube Community Build to import the repositories. This token will be stored in SonarQube Community Build and can be revoked at any time in GitLab.

You can either provide:

* A [personal access token](https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html).\
  We recommend using a dedicated GitLab account with at least Reporter [permissions](https://docs.gitlab.com/ee/user/permissions.html). Use a personal access token from this account with the `api` scope authorized for the repositories you’re analyzing.
* Or a [Group Access Token](https://docs.gitlab.com/ee/user/group/settings/group_access_tokens.html) with at least the Reporter role and with the `api` scope.

If you want to enter the token in SonarQube Community Build in encrypted format, you can encrypt this token. See [encrypting-settings](https://docs.sonarsource.com/sonarqube-community-build/instance-administration/security/encrypting-settings "mention") for more information.

</details>

## Setting up the import of GitLab repositories <a href="#repos-import" id="repos-import"></a>

With this setup, users will be able to [importing-repos](https://docs.sonarsource.com/sonarqube-community-build/devops-platform-integration/gitlab-integration/importing-repos "mention") into SonarQube Community Build.

This integration is performed through a "GitLab Configuration" record, which is used in SonarQube Community Build to access the GitLab instance. You need the Administration System permission to set up a GitLab Configuration.

{% hint style="info" %}
With SonarQube Server Enterprise, you can integrate SonarQube Server with multiple GitLab instances, each instance being accessed with a different GitLab Configuration. For more information, see [feature-comparison-table](https://docs.sonarsource.com/sonarqube-community-build/feature-comparison-table "mention").
{% endhint %}

To set up a GitLab Configuration in SonarQube Community Build:

1. In the SonarQube Community Build UI, go to **Administration > Configuration > General Settings > DevOps Platform Integrations**.
2. Select the **GitLab** tab and click **Create configuration**. The **Create a configuration** dialog opens.
3. Specify the following settings:
   * **GitLab URL**: The GitLab API URL. We recommend using `https://gitlab.com/api/v4`. You can also use your own GitLab server URL.
   * **Personal Access Token**: GitLab token you created in **Preparing the integration** above.
4. Select Save configuration.

## Setting up user provisioning and authentication <a href="#authentication" id="authentication"></a>

See [setting-up](https://docs.sonarsource.com/sonarqube-community-build/instance-administration/authentication/gitlab/setting-up "mention").
