Connect to a GitLab repository Stay organized with collections Save and categorize content based on your preferences.
This page explains how to connect aGitLab repository to Cloud Build. To learn more about Cloud Build repositories, seeCloud Build repositories.
Before you begin
Enable the Cloud Build and Secret Manager APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission.Learn how to grant roles.
- Follow the instructions toconnect a GitLab host before connecting repositories.
Connect to a GitLab repository
Console
Open theRepositories page in the Google Cloud console.
You see theRepositories page.
At the top of the page, select the2nd gen tab.
In the project selector in the top bar, select your Google Cloud project.
ClickLink repository to link repositories from your connection.
You see theLink repository panel.
In theLink repository panel, enter the following information:
- Connection: Select a connection from the drop-down menu.
Repository: Select a repository to link to your connection.
Repository Name: Enter a name for your repository.
- Generated: Select this option for Cloud Build to automaticallygenerated repository names on your behalf for selected repositories.
Manual: Select this option to manually specify names for yourselected repositories.
If you selectManual, you can modify the names for yourselected repositories in theRepository names section.
ClickLink to link your repository to your connection.
gcloud
To add a GitLab repository to your connection, enter the followingcommand:
gcloudbuildsrepositoriescreateREPO_NAME\--remote-uri=REPO_URI\--connection=CONNECTION_NAME--region=REGIONWhere:
- REPO_NAME is the name of your repository.
- REPO_URI is the link to your GitLab repository.
- CONNECTION_NAME is the name given to the GitLab connection created in Cloud Build fromConnect to a GitLab host.
- REGION is theregion for your connection.
You have now linked a repository to your GitLab connection.
What's next
- Learn how tobuild repositories from GitLab.
- Learn how to build and deploy your workloads to Google Cloud using Google-managed CI/CD components in your GitLab pipeline. SeeGitLab on Google Cloud.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-19 UTC.