Skip to content
Last updated on February 6, 2023
4 min read

Vercel for GitLab automatically deploys your GitLab projects with Vercel, providing Preview Deployment URLs, and automatic Custom Domain updates.

The Deploying a Git repository guide outlines how to create a new Vercel Project from a GitLab repository, and enable automatic deployments on every branch push.

If you'd like to connect your Vercel Project to a different GitLab repository or disconnect it, you can do so from the Git section in the Project Settings.

Vercel for GitLab will deploy each push by default. This includes pushes and pull requests made to branches. This allows those working within the project to preview the changes made before they are pushed to production.

With each new push, if Vercel is already building a previous commit, the current build will be canceled to build the most recent commit so that you always have the latest changes deployed as quickly as possible.

If Custom Domains are set from a project domains dashboard, pushes and merges to the Production Branch (commonly "main") will be made live to those domains with the latest deployment made with a push.

If you decide to revert a commit that has already been deployed to production, the previous Production Deployment from a commit will automatically be made available at the Custom Domain instantly; providing you with instant rollbacks.

The latest push to any merge request will automatically be made available at a unique preview URL based on the project name, branch, and team or username. These URLs will be provided through a comment on each merge request.

A preview URL created from a merge request.

You may want to use different workflows and APIs based on Git information. To support this, the following System Environment Variables are exposed to your Deployments:

The Git Provider the deployment is triggered from. In the case of GitLab, the value is always gitlab.
The GitLab name of the deployed project. Example: my-site.
The GitLab user, group, or sub-group that the project belongs to. Example: acme.
The GitLab ID of the deployed project. Example: 13343236.
The GitLab branch that the deployment was triggered by. Example: improve-about-page.
The GitLab sha of the commit the deployment was triggered by. Example: fa1eade47b73733d6312d5abfad33ce9e4068081.
The message accompanying the GitLab commit that the deployment was triggered by. Example: Add John Doe to about page.
The username belonging to the author of the commit that was deployed on GitLab. Example: johndoe.
The name belonging to the author of the commit that was deployed on GitLab. Example: John Doe.
The GitLab merge request id the deployment was triggered by. If a deployment is created on a branch before a merge request is made, this value will be an empty string. Example: 23.

We require some permissions through our Vercel for GitLab integration. Below are listed the permissions required and a description for what they are used for.

Allows us access to the API—including all groups and projects, the container registry, and the package registry—to clone repositories and add comments to pull requests and commits.
Note: We use the permissions above in order to provide you with the best possible deployment experience. If you have any questions or concerns about any of the permission scopes, please contact Vercel Support.

To sign up on Vercel with a different GitLab account, sign out of your current GitLab account.

Then, restart the Vercel signup process.

When importing or connecting a GitLab repository, we require that you have Maintainer access to the corresponding repository, so that we can configure a webhook and automatically deploy pushed commits.

If a repository is missing when you try to import or connect it, make sure that you have Maintainer access configured for the repository.

You can use GitLab Pipelines to build and deploy your Vercel Application.

vercel build allows you to build your project inside GitLab Pipelines, without exposing your source code to Vercel. Then, vercel deploy --prebuilt skips the build step on Vercel and uploads the previously generated .vercel/output folder to Vercel from the GitLab Pipeline.

Learn more about how to configure GitLab Pipelines and Vercel for custom CI/CD workflows.