Connect to a GitLab Enterprise Edition repository

This page explains how to connect a GitLab Enterprise Edition repository to Cloud Build. To learn more about Cloud Build repositories, see Cloud Build repositories.

Before you begin

  • Enable the Cloud Build and Secret Manager APIs.

    Enable the APIs

Connect to a GitLab Enterprise Edition repository

Console

  1. Open the Repositories page in the Google Cloud console.

    Open the Repositories page

    You will see the Repositories page.

  2. At the top of the page, select the 2nd gen tab.

  3. In the project selector in the top bar, select your Google Cloud project.

  4. Click Link repository to link repositories from your connection.

    You will see the Link repository panel.

  5. In the Link repository panel, enter the following information:

    1. Connection: Select a connection from the drop-down menu.
    2. Repository: Select a repository to link to your connection.

    3. Repository Name: Enter a name for your repository.

      1. Generated: Select this option for Cloud Build to automatically generated repository names on your behalf for selected repositories.
      2. Manual: Select this option to manually specify names for your selected repositories.

        If you select Manual, you can modify the names for your selected repositories in the Repository names section.

  6. Click Link to link your repository to your connection.

You have now successfully linked your GitLab Enterprise Edition repository to your connection.

gcloud

To add a GitLab Enterprise Edition repository to your connection, enter the following command:

   gcloud builds repositories create REPO_NAME \
     --remote-uri=REPO_URI \
     --connection=CONNECTION_NAME --region=REGION

Where:

  • REPO_NAME is the name of your repository.
  • REPO_URI is the link to your GitLab Enterprise Edition repository. For example, https://gitlab-enterprise.com/myuser/myrepo.git.
  • CONNECTION_NAME is the name of your connection.
  • REGION is the region for your connection.

You have now linked a repository to your GitLab Enterprise Edition connection.

Terraform

To add a GitLab Enterprise Edition repository to your connection, add the following code snippet to your Terraform configuration:

    resource "google_cloudbuildv2_repository" "my-repository" {
      project = "PROJECT_ID"
      name = "REPO_NAME"
      location = :REGION"
      parent_connection = google_cloudbuildv2_connection.my-connection.name
      remote_uri = "REPO_URI'
  }

Where:

  • PROJECT_ID is your Google Cloud project ID.
  • REPO_NAME is the name of your GitLab Enterprise Edition repo.
  • REGION is the region for your connection.
  • REPO_URI is the remote URI of your repository. For example, https://gitlab-enterprise.com/myuser/myrepo.git.

You have now linked a repository to your GitLab Enterprise Edition connection.

What's next