Skip to main content

Connect to GitLab

Connecting your GitLab account to dbt provides convenience and another layer of security to dbt:

  • Import new GitLab repos with a couple of clicks during dbt project setup.
  • Clone repos using HTTPS rather than SSH.
  • Carry GitLab user permissions through to dbt and dbt CLI git actions.
  • Trigger continuous integration builds when merge requests are opened in GitLab.
info

When configuring the repository in dbt, GitLab automatically:

  • Registers a webhook that triggers pipeline jobs in dbt.
  • Creates a project access token in your GitLab repository, which sends the job run status back to GitLab using the dbt API for CI jobs. dbt automatically refreshes this token for you.

You must have a GitLab Premium or Ultimate account.

Depending on your plan, use these steps to integrate GitLab with dbt:

  • For the Developer or Starter plans, follow these instructions.
  • For the Enterprise or Enterprise+ plans, follow these instructions.

For dbt Developer and Starter plans

Before you can work with GitLab repositories in dbt, you’ll need to connect your GitLab account to your user profile. This allows dbt to authenticate your actions when interacting with Git repositories. Make sure to read the requirements and limitations of the Starter and Developer plans before you connect your account.

To connect your GitLab account:

  1. From dbt, click on your account name in the left-side menu and select Account settings.
  2. Select Personal profile under the Your profile section.
  3. Go to Linked accounts.
  4. Click Link to the right of your GitLab account.
  5. In GitLab, sign in if prompted. When an authorization prompt appears, select the option to authorize dbt.

After you authorize the request, you’ll be redirected back to dbt, and you'll see that your account has been linked to your profile.

Requirements and limitations

dbt Starter and Developer plans use a single GitLab deploy token created by the first user who connects the repository, which means:

  • All repositories that users access from the dbt platform must belong to a GitLab group.
  • All Git operations (like commits and pushes) from the Studio IDE appear as coming from the same deploy token.
  • GitLab push rules may reject pushes made through dbt, particularly when multiple users are committing via the same deploy token.

To support advanced Git workflows and multi-user commit behavior, upgrade to the Enterprise plan, which provides more flexible Git authentication strategies.

For the dbt Enterprise plans

dbt Enterprise and Enterprise+ customers have the added benefit of bringing their own GitLab OAuth application to dbt. This tier benefits from extra security, as dbt will:

  • Enforce user authorization with OAuth.
  • Carry GitLab's user repository permissions (read/write access) through to dbt or dbt CLI git actions.

In order to connect GitLab in dbt, a GitLab account admin must:

  1. Set up a GitLab OAuth application.
  2. Add the GitLab app to dbt.

Once the admin completes those steps, dbt developers need to:

  1. Personally authenticate with GitLab from dbt.

Setting up a GitLab OAuth application

We recommend that before you set up a project in dbt, a GitLab account admin set up an OAuth application in GitLab for use in dbt.

For more detail, GitLab has a guide for creating a Group Application.

To create a group-owned OAuth application in GitLab:

  1. In GitLab, navigate to your group settings and select Applications.

    GitLab application navigationGitLab application navigation
  2. When creating your group application, enter the following:

    FieldValue
    Namedbt
    Redirect URIhttps://YOUR_ACCESS_URL/complete/gitlab
    Confidential
    Scopes✅ api
    Loading table...

    For the Redirect URI field, replace YOUR_ACCESS_URL with the appropriate Access URL for your region and plan.

  3. Click Save application. GitLab will generate an Application ID and Secret. These values remain available even if you close the app screen, so you can return to save them later.

If you're a Business Critical customer using IP restrictions, ensure you've added the appropriate GitLab CIDRs to your IP restriction rules, or else the GitLab connection will fail.

Adding the GitLab OAuth application to dbt

After you've created your GitLab application, add it to dbt:

  1. In dbt, go to Account settings > Integrations, then expand the GitLab section.

  2. Enter the following values:

    FieldValue
    GitLab Instancehttps://gitlab.com
    Application IDcopy value from GitLab app
    Secretcopy value from GitLab app
    Loading table...

    If you use a self-hosted GitLab instance, set GitLab Instance to your organization’s GitLab hostname (for example, https://gitlab.yourgreatcompany.com).

  3. Click Save.

  4. You will then be redirected to GitLab and prompted to sign in.

  5. When an authorization prompt appears, select the option to authorize dbt.

After you authorize the request, you’ll be redirected back to dbt. Your integration is now ready for developers on your team to personally authenticate with GitLab.

Personally authenticating with GitLab

dbt developers on the Enterprise or Enterprise+ plan must each connect their GitLab profiles to dbt, as every developer's read/write access for the dbt repo is checked in the Studio IDE or dbt CLI.

To connect a personal GitLab account:

  1. From dbt, click on your account name in the left-side menu and select Account settings.
  2. Select Personal profile under the Your profile section.
  3. Go to Linked accounts.
  4. If your GitLab account is not connected, you’ll see "No connected account". Select Link to begin the setup process.
  5. In GitLab, sign in if prompted. When an authorization prompt appears, select the option to authorize dbt.

Once you approve authorization, you will be redirected to dbt, and you should see your connected account. You're now ready to start developing in the Studio IDE or dbt CLI.

Troubleshooting

Unable to trigger a CI job with GitLab
Errors importing a repository on dbt project set up
How can I fix my .gitignore file?
I'm seeing a Gitlab authentication out of date error loop
Can self-hosted GitLab instances only be connected via dbt Enterprise plans?
How to migrate git providers
GitLab token refresh message

Was this page helpful?

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

0
Loading