# Connect GitLab > How to connect GitLab by signing in, in a few clicks, or with an access token (also for self-hosted GitLab), for private projects, deploy on every push and merge request previews. The panel uses the GitLab connection to clone private projects, deploy on every push and comment on merge requests with the preview address. Public gitlab.com projects work without a connection for manual deploys. ## Two ways to connect | | GitLab login (recommended) | Access token | |---|---|---| | How it connects | Click **Connect with GitLab**, authorize and come back connected | Create a token in GitLab and paste it in the panel | | Where | gitlab.com | gitlab.com or your own GitLab (self-hosted) | | Projects | The ones your account can push to | The ones the token can see | | Validity | The panel renews access by itself | The token expires when you chose | | Merge request comment | Shows up as your account | Shows up as the token's account (or bot) | Either way, deploy on every push and previews use a webhook on each project, created by the panel. ![GitLab page in the panel with one login connection and one token connection](https://ployter.com/assets/docs/en/gitlab-page.webp) ## Connect by signing in (gitlab.com) You need the **Manage GitHub and GitLab connections** permission in the panel. By default, owners and admins have it. 1. In the panel, open **Integrations → GitLab** and click **Connect with GitLab**. 2. Sign in to GitLab, if you aren't signed in yet. 3. GitLab shows Ployter's access request (`api` scope). Click **Authorize**. 4. You come back to the panel and the connection shows up in the list with the **Login** badge and the account name. GitLab access lasts 2 hours, and the panel renews it by itself when needed. Connecting the same account again only updates the existing connection. To revoke Ployter's access for good, revoke it in **Preferences → Applications** in GitLab. Removing the connection in the panel doesn't revoke the authorization there. > [!NOTE] > A login connection isn't copied to other teams by **Import from another team**. In each team, click **Connect with GitLab**. ## Connect with an access token Use a token for your own GitLab, for a group token (which doesn't depend on one person's account) or if you'd rather not authorize the login. 1. In GitLab, open **Preferences → Access tokens** and create a token with the `api` scope. Instead of a personal token, you can create a group or project token, under the group's or project's **Settings → Access tokens**. 2. In the panel, open **Integrations → GitLab** and click **Use a token**. 3. Give it a name, paste the token and, for your own GitLab, fill in the **GitLab address** (for example, `https://git.yourcompany.com`). For gitlab.com, leave it empty. 4. Click **Save**. The panel checks the token with GitLab before saving and stores it encrypted. ![New GitLab token modal with the address of a self-hosted GitLab](https://ployter.com/assets/docs/en/gitlab-token-modal.webp) The role on the project decides what works: | Role | What works | |---|---| | Developer | Listing, cloning and manual deploys | | Maintainer | Everything, including the webhook for deploy on every push and previews | To replace an expired token, click the connection's pencil and paste the new one. ## Use the connection in a service 1. In the project, click **New service** and pick **Git repository**. 2. Under **Repository**, the list shows each connection's projects, GitHub and GitLab, grouped by account. Pick the project: the default branch is already selected. 3. Check the branch and the folder (in a monorepo) and click **Create service**. ![Repository list with one GitHub connection and one GitLab connection](https://ployter.com/assets/docs/en/gitlab-repo-picker.webp) Groups and subgroups show up in the path, for example `acme/backend/pagamentos`. For a public gitlab.com project, use **Paste a public repository URL** and paste the address, without a connection. A project on your own GitLab needs a connection with its address: the panel only accepts that address together with the credential. ## Deploy on every push With **Automatic deploy** on in the service, the panel creates a webhook on the GitLab project (push and merge request events). Each push to the service's branch deploys that commit. Tag pushes and deleted branches are ignored. The webhook is removed by itself when no service uses the project with automatic deploy or previews anymore. > [!WARNING] > Without the Maintainer role, GitLab doesn't let the panel create the webhook. The service is saved with a warning, and manual deploys keep working. ## Merge request previews Under the service's **Settings → Merge request previews**, each merge request to the service's branch brings up a copy with the MR code, at its own address. The panel comments on the MR with the link and edits the same comment on every push. The preview goes away when the MR is closed or merged. A draft merge request only gets a preview when it leaves draft. Merge requests from forks don't get a preview, because outside code would run with the service's variables. See [Previews](https://ployter.com/en/docs/services/previews/). ## Remove the connection In the list, click the connection's trash icon. Services that used it are left without a credential: a private project stops cloning until you pick another one. Webhooks already created stay in GitLab; incoming pushes are ignored.