Connect to GitLab Enterprise repositories in a private network Stay organized with collections Save and categorize content based on your preferences.
These instructions are for application developers, platform administrators, andsecurity managers who want to use GitLab Enterprise source code repositories with Google.Specifically, you can use GitLab Enterprise repositories withGemini Code Assist.
Note: Developer Connect also supports GitLab Community Edition. The stepsin this document are for both GitLab Enterprise repositories and GitLabCommunity Edition repositories.To learn more about Developer Connect, seeDeveloper Connect overview.
Before you begin
- Sign in to your Google Account.
If you don't already have one, sign up for a new account.
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect and Service Directory 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.In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Note: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- Create a project: To create a project, you need the Project Creator role (
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission.Learn how to grant roles.
Verify that billing is enabled for your Google Cloud project.
Enable the Developer Connect and Service Directory 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.Ensure that you have access to an account onGitLab Enterprise.
To help keep your team's work secure, we recommend that you complete the tasks in this guide using aservice account or an account shared by your team, not a personal account.
- Ensure that you own a GitLab Enterprise repository, or have admin-level permissions ona shared repository.
- Ensure that you have a Service Directory service resource forconnecting to private networks, orcreate aService Directory service resource. You can create theService Directory service resource in the same project thatyou're using with Developer Connect, or you can use a different project.
For connections to networks outside of Google Cloud, you might need toconfigure Service Directory differently. SeeUse Service Directory to reach hostsoutside Google Cloud.
- Optional: Create acustomer-managedencryption key (CMEK) for encrypting the authentication secrets thatDeveloper Connect creates.
- Optional: To use the command-line instructions in this guide, complete thefollowing steps:
- Install theGoogle Cloud CLI. If you've installed gcloud CLI previously, make sure you have the latest available version by running
gcloud components update. - Create aDeveloper Connect service account by running the following command, wherePROJECT_ID is yourGoogle Cloud project ID:
gcloudbetaservicesidentitycreate\--service=developerconnect.googleapis.com\--project=PROJECT_ID
- Install theGoogle Cloud CLI. If you've installed gcloud CLI previously, make sure you have the latest available version by running
Enabling Developer Connect also enables theSecret Manager API.
Required roles
To get the permissions that you need to create connections and links, ask your administrator to grant you the following IAM roles:
- If you aren't the project owner:Developer Connect Admin (
roles/developerconnect.admin) on your user account. - If you plan to use a CMEK to encrypt the secrets that Developer Connect creates:Cloud KMS CryptoKey Encrypter/Decrypter (
roles/cloudkms.cryptoKeyEncrypterDecrypter) on the Secret Manager Service Account. - If you plan to use the gcloud CLI to complete the steps in this guide:Secret Manager Admin role (
roles/secretmanager.admin) on the Developer Connect Service Account. - If you plan to use the Google Cloud console to complete the steps in this guide:Project IAM Admin (
roles/resourcemanager.projectIamAdmin) on your user account.
For more information about granting roles, seeManage access to projects, folders, and organizations.
You might also be able to get the required permissions throughcustom roles or otherpredefined roles.
Note: When you have the Project IAM Admin(roles/resourcemanager.projectIamAdmin) role, the Google Cloud console canautomatically grant necessary permissions on your behalf. If your administratorwon't allow you to have the Project IAM Admin role, then ask your administratorto grant Secret Manager Admin (roles/secretmanager.admin) on theDeveloper Connect Service Account(service-{projectNumber}@gcp-sa-devconnect.iam.gserviceaccount.com).Grant permissions to use Service Directory
Complete the following steps to let Developer Connect useService Directory, and to let Service Directoryaccess your VPC network resource.
Grant permissions for the Developer Connect service account to useService Directory by running the following commands:
PROJECT_NUMBER=$(gcloudprojectsdescribePROJECT_ID--format="value(projectNumber)")SERVICE_ACCOUNT="service-${PROJECT_NUMBER}@gcp-sa-devconnect.iam.gserviceaccount.com"gcloudprojectsadd-iam-policy-bindingSERVICE_DIRECTORY_RESOURCE_PROJECT_ID\--member="serviceAccount:${SERVICE_ACCOUNT}"\--role="roles/servicedirectory.viewer"Replace the following:
- PROJECT_ID: your Google Cloud project ID.
- SERVICE_DIRECTORY_RESOURCE_PROJECT_ID: theproject ID for the Google Cloud project that contains yourService Directory service resource.
Grant permissions for Service Directory to access your VPCnetwork resource. The network resource can be in a different project.
gcloudprojectsadd-iam-policy-bindingNETWORK_RESOURCE_PROJECT_ID\--member="serviceAccount:${SERVICE_ACCOUNT}"\--role="roles/servicedirectory.pscAuthorizedService"ReplaceNETWORK_RESOURCE_PROJECT_ID with the projectID for the project that contains your VPC network resource.
Use Service Directory to reach hosts outside Google Cloud
Service Directory uses the IP address range35.199.192.0/19 toconnect your host outside of Google Cloud. You must add this range toan allowlist in your firewall. Additionally, your private network needs to beconfigured to route this range through the Cloud VPN or Cloud Interconnectconnection.
If your connection uses a Cloud Router, you can configure your connection tocommunicatethe range to your private network.
To learn more, seeConfigure private network access.
Use Cloud Load Balancing to reach hosts outside Google Cloud
If your network configuration does not allow you to route theService Directory IP address range35.199.192.0/19 to theCloud VPN or Cloud Interconnect, you cancreate a load balancer usingCloud Load Balancing that directs traffic to your host.
When you create the Service Directory endpoint, make sure to usethe IP address of the forwarding rule of the load balancer instead of the IPaddress of your host. You can use aninternal HTTPS load balanceror aninternal transmission control protocol (TCP) load balancerwhen creating your endpoint.
When creating your TCP load balancer, consider the following:
- Only a hybrid connectivity network endpoint group (NEG) is required to reachyour host.
- The TCP load balancer does not require the unencrypted private key for yourSSL certificate.
- Your Cloud VPN setup needs to use Cloud Router with globaldynamic routing. If your Cloud VPN uses static routing, you can usea proxy that uses Cloud Service Mesh instead. To learn more, seeSet up networkedge services for hybriddeployments.
To learn more about creating an HTTPS load balancer, seeSet up an internal Application Load Balancer with hybrid connectivity.To learn more about creating a TCP load balancer, seeSet up a regional internal proxy Network Load Balancer with hybrid connectivity.
Create access tokens
Create personal access tokens in GitLab by completing the following steps:
Follow the instructions in the GitLab documentation tocreate personal access tokens with the followingpermissions:
- One token with
apiscope for connecting and disconnecting repositories. - One token with
read_apiscope to allow Developer Connect to readsource code in your repositories.
- One token with
Create a connection
This section describes how to create a connection between Developer Connectand GitLab Enterprise. If you're using the Google Cloud console, then you can also startadding links to repositories as you finish setting up your connection.
To create a new GitLab Enterprise connection, select one of the following options:
Console
Initiate a connection by completing the following steps:
In the Google Cloud console, openDeveloper Connect.
Developer Connect displays theGit repositories page.
- If you see a list of source code management providers: Start configuring your first connection by selecting a source code management provider. ClickConnect on the GitLab Enterprise card.
If you see a table listing existing connections: Set the source code management provider by clickingCreate connection >GitLab Enterprise.
TheCreate Connection page opens.
ForRegion, choose aregionfor your connection resources.
- ForName, enter a name for your new connection.
In thePersonal Access Tokens section,enter thetokensfor your account:
- API access token: Enter the personal access token with
apiscope. - Read API access token: Enter the personal access token with
read_apiscope.
You are responsible for ensuring your GitLab tokens remain valid.GitLab tokens have a maximum lifetime of 365 days, unless otherwisespecified by the token creator or an administrator. To learn how tomanage token expiration settings and notifications, see the GitLabdocumentation onpersonal access tokens.
For more information, see GitLab's documentation onpersonal access token expiration.
- API access token: Enter the personal access token with
ForHost URL, enter the URL of the host you want to connect to.
ClickShow more to see optional configuration settings.
TheEnable Developer Connect proxy checkbox is selected bydefault so that Developer Connect can act as a proxy for Git callsto GitLab Enterprise.
In theNetworking section, forNetwork type, choosePrivatenetwork.
ForCA Certificate, clickBrowse to upload your self-signedcertificate.
Your certificate must not exceed 10 KB in size and should be inPEM format (.pem, .cer, or .crt). If this section is left blank,a default set of certificates will be used in place.
In theService Directory service section, select the location ofyour service:
- In project
your-project - In another project
- Enter manually
If you selectIn another project orEnter manually, specifyyour Google Cloud project ID. Select the project in thedrop-down menu, or enter the project ID manually.
- In project
Region: Select the region of yourService Directory service. The region specifiedfor your service must match the region associated with yourconnection.
Namespace: Select the namespace of yourService Directory service.
Service: Select the Service Directory service namein your namespace.
Optional: In theEncryption section, select aCMEK key toencrypt Secret Manager secrets that Developer Connectcreates.
ClickContinue.
Once the connection is created, theLink repositories page appears.
Complete the following steps to link repositories to your connection:
In the list of available repositories, select the repositoriesyou want to use.
ClickOK.
ClickLink.
Your connection is added to theConnections page and your repositorylinks are added to theRepositories page in the Google Cloud console.You canadd more links to existing connections at any time.
If you're setting up Gemini Code Assist, continue the processby following the steps inConfigure and use Gemini Code Assist code customization.
gcloud
Create a webhook secret in Secret Managerby running the following command, whereWEBHOOK_SECRET_NAMEis a name for your webhook secret:
cat/proc/sys/kernel/random/uuid|tr-d'\n'|gcloudsecretscreateWEBHOOK_SECRET_NAMEStore your personal access tokens in Secret Manager by runningthe following commands:
gcloudsecretscreateAPI_SECRET_NAMEecho-nAPI_SECRET_DATA|gcloudsecretsversionsaddAPI_SECRET_NAME--data-file=-gcloudsecretscreateREAD_SECRET_NAMEecho-nREAD_SECRET_DATA|gcloudsecretsversionsaddREAD_SECRET_NAME--data-file=-Replace the following:
- API_SECRET_NAME: a name for the secret that storesthe token with
apiscope. - API_SECRET_DATA: the token with
apiscope, similar toglpat-XXXXXXXXXXXXXXXX. - READ_SECRET_NAME: a name for the secret that storesthe token with
read_apiscope. - READ_SECRET_DATA: the token with
read_apiscope, similar toglpat-XXXXXXXXXXXXXXXX.
- API_SECRET_NAME: a name for the secret that storesthe token with
Run thegcloud developer-connect connections create command to create a connection to GitLab Enterprise:
gcloudbetadeveloper-connectconnectionscreateCONNECTION_NAME\--location=REGION\--gitlab-config-read-authorizer-credential-user-token-secret-version=projects/PROJECT_ID/secrets/READ_SECRET_NAME/versions/VERSION\--gitlab-config-authorizer-credential-user-token-secret-version=projects/PROJECT_ID/secrets/API_SECRET_NAME/versions/VERSION\--gitlab-enterprise-config-host-uri=HOST_URI--gitlab-enterprise-config-webhook-secret-version=projects/PROJECT_ID/secrets/WEBHOOK_SECRET_NAME/versions/VERSION--git-proxy-config-enabledReplace the following:
- CONNECTION_NAME: the name of your connection.
- REGION: the region for your connection.
- PROJECT_ID: your Google Cloudproject ID.
- READ_SECRET_NAME: the name of theSecret Manager secret that contains the tokenwith
read_apiscope. - API_SECRET_NAME: the name of theSecret Manager secret that contains the tokenwith
apiscope. - VERSION: the version number of each secret. Thiscan be
latestto use the most recent version number. - HOST_URI: the URI for the host you want toconnect to.
- WEBHOOK_SECRET_NAME: the name of theSecret Manager secret that contains your webhooksecret.
--git-proxy-config-enabledis an optional flag that allowsDeveloper Connect to as a proxy for Git calls toGitLab Enterprise. You must enable this feature when runningGemini Code Assist code customizationon GitLab Enterprise source code repositories hosted in private networks.--gitlab-enterprise-config-ssl-ca-certificateis an optional flagto add an SSL certificate, in the format$HOME/my-ssl-ca.txt.
Developer Connect completes the connection to GitLab. Next,link to repositories.
Link to repositories using an existing connection
Once you have established a connection to GitLab Enterprise, you can link torepositories. You can repeat these steps later to link additional repositoriesas needed.
To create repository links on an existing GitLab Enterprise connection, select one of thefollowing options:
Console
Create links to repositories by completing the following steps:
Open theRepositories page in the Google Cloud console.
ClickLink repository.
TheLink Git repositories pane opens.
In the connections list, choose a connection.
ClickContinue.
In the repositories list, select the repositories you want to link to.
Developer Connect displays suggested names for your repositoryresources.
Select a repository resource naming option:
- Generated: Use the generated repository resource names.
- Manual: Input names of your own.
ClickCreate.
Developer Connect creates the repository links and displays them inthe Google Cloud console.
gcloud
Link to a GitLab repository by running the following command:
gcloudbetadeveloper-connectconnectionsgit-repository-linkscreateREPO_NAME\--clone-uri=REPO_URI\--connection=CONNECTION_NAME\--location=REGIONReplace the following:
- REPO_NAME: the name for your repository link.
- REPO_URI: the link to your repository, similarto
https://gitlab.com/my-project/test-repo.git. - CONNECTION_NAME: the name of your connection.
- REGION: the region of your connection.
Developer Connect creates the repository links.
To list linked repositories, run thedeveloper-connect connections git-repository-links list command.
If you're setting up Gemini Code Assist, continue the processby following the steps inConfigure and use Gemini Code Assist code customization.
What's next
- Finish setting up Gemini Code Assist code customization.
- Learn how Gemini Code Assist helps you accelerate software development.
- Explore other integrations available through Developer Connect.
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.