Skip to main content

Syncing to Gitlab

You can sync your Modelbit git repo to a repo in your company's Gitlab account. This is especially valuable for using your Gitlab-based code review, CI/CD and Pull Request workflows on your Modelbit deployments.

This workflow requires you to have admin permissions within your Gitlab account.

tip

You should create a new, empty git repository for Modelbit.

Adding your Gitlab repo URL to Modelbit

First, make a new Gitlab repo inside your Gitlab account.

Once created, from the main page of your Gitlab repo, click the blue Clone button and copy out the URL. The URL will look like git@github.com:your-organization/repo-name.



Head back to Modelbit:

  1. In Settings, open the Git Settings page.
  2. Click the Gitlab button, then click Next.
  3. Paste in the URL of your GitHub repo and click Next.

Before heading back to Gitlab, copy the Deploy Key. This Deploy Key is Modelbit's public key for pushing and pulling your Git repo, just like a user's public key. It is not a secret.

Adding your Modelbit deploy key to Gitlab

Open your repo in Gitlab, then:

  1. On the left hand side, hover over Settings and click Repository.
  2. Click the "Expand" button next to Deploy Keys.
  3. Paste in the Modelbit deploy key in the Key field. Give the key a memorable title, like "Modelbit Integration".

Make sure to check "Grant write permissions to this key". Click Add Key.

tip

You must check the Grant write permissions to this key box in order for Modelbit to push changes to this repository.



Head back to Modelbit, click Next, and Modelbit will test the connection to Gitlab. If the Deploy Key has been set with write access and no branch protection rules prevent Modelbit from syncing with the repo, you're all set.

Now Modelbit will sync to your Gitlab repo, allowing you to use Gitlab Merge Requests for merges, and all your Gitlab-based tools for CI/CD, code review and more!

tip

Do not use git clone with this repository, use modelbit clone. The modelbit clone command will git clone your repo and configure it to handle binary files like pkls.

Gitlab Webhooks

To ensure the quickest sync between Gitlab and Modelbit, configure Gitlab to notify Modelbit of changes using GitHub webhooks.

You'll find Modelbit's Webhook URL and Secret in the Git Settings page.

In Gitlab, go to your repository's settings area and:

  1. Click Webhooks
  2. Paste Modelbit's Webhook URL into the URL field
  3. Paste Modelbit's Webhook Secret into the Secret token field
  4. Check the Push events box under Triggers
  5. Click Add webhook

The next time you push changes to Gitlab, Modelbit will be notified and immediately sync the changes.