Setting up the GitLab integration at the 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.
Preparing the integration
Verifying the server base URL
For the GitLab integration to work:
- The SonarQube Community Build base URL must be a public URL.
- If you want to delegate the SonarQube Community Build user authentication to GitLab: you must use HTTPS. This means that the SonarQube Community Build must be secured behind a proxy.
You must configure your SonarQube Community Build base URL in SonarQube Community Build, otherwise, integration features will not work correctly.
To verify the server base URL configuration in SonarQube Community Build:
- Go to Administration > Configuration > General Settings > General > General and check the instance's Server base URL.
Generating a token
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.
We recommend using a dedicated GitLab account with at least Reporter permissions. Use a personal access token from this account with theapi
scope authorized for the repositories you're analyzing. - Or a Group Access Token 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 sensitive settings for more information.
Setting up the import of GitLab repositories
With this setup, users will be able to import GitLab repositories 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.
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 SonarQube Community Build feature support.
To set up a GitLab Configuration in SonarQube Community Build:
- In the SonarQube Community Build UI, go to Administration > Configuration > General Settings > DevOps Platform Integrations.
- Select the GitLab tab and click Create configuration. The Create a configuration dialog opens.
- 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.
- GitLab URL: The GitLab API URL. We recommend using
- Select Save configuration.
Setting up user provisioning and authentication
Was this page helpful?