How to Connect Teamscale to GitLab
Teamscale communicates with GitLab using its REST API and web hooks. You don't need to install plugins in GitLab or change admin settings.
General Option Reference
This guide only covers the options specific for the GitLab repository connector. A general overview of connector options is available here.
To connect a project to code from a GitLab project, follow these steps:
Ensure that the Teamscale instance base URL is configured correctly.
Select the GitLab connector during project creation.
Select or create an account for the GitLab server:
The account's URL should point to the GitLab server's root URL (i.e., it is not project specific).
The username can be empty (ignored).
The password is a personal access token of a GitLab user with api scope.
To obtain a personal access token in GitLab, navigate to your user's settings page and select the Access Tokens page. Additionally, to allow Teamscale to create web hooks in a project, the user needs to be a Maintainer of that project. Note that you can also create the web hooks manually
Complete project creation as usual, by providing the name (e.g.,
my-user/my-project
) or ID (e.g.,12345678
) of the GitLab project and completing any other required fields. As the first step in project creation, Teamscale will register its web hook with the project. After this, Teamscale will automatically be informed about events in the project, such as pushes to the repository and changes to any merge requests.
Manual Creation of Webhooks
In case the technical user does not have at least a Maintainer role, you will need to manually create and configure webhooks in the GitLab repository.
- Open the GitLab repository you want to add the webhook to.
- From Settings, click Webhooks.
- Configure the webhook as follows:
- URL: Enter the URL of Teamscale's GitLab endpoint. It should be in the following format:
<Teamscale_baseURL>/api/gitlab/web-hook
- Trigger: Select the following triggers:
- Push events
- Merge request events
- URL: Enter the URL of Teamscale's GitLab endpoint. It should be in the following format:
- Click Add webhook.
TIP
If there are restrictions, so that Teamscale cannot receive GitLab web hooks or web hooks cannot be automatically created, please apply these advanced configuration options.