关联源代码库
借助 Developer Connect,您可以与非 Google 产品和服务集成,以便在受支持的 Google 产品中使用它们。
本快速入门介绍如何使用 Git 代码库连接连接到 GitHub。如果您想使用 Gemini Code Assist 代码自定义,则必须建立此类连接。
如需查看 Developer Connect 支持的所有集成,请参阅 Developer Connect 概览。
准备工作
- 登录您的 Google Cloud 账号。如果您是 Google Cloud新手,请 创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 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.-
Make sure that you have the following role or roles on the project: Developer Connect Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud 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 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.-
Make sure that you have the following role or roles on the project: Developer Connect Admin
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.
- For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.
Grant the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- Click Select a role, then search for the role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
- 确保您拥有 GitHub 账号,并且有权访问 GitHub.com 上托管的代码库。或者,按照 GitHub 文档创建新的账号和代码库:
- 如果您使用的是现有代码库,但您不是所有者,请让所有者向您授予对该代码库的管理级权限。如果代码库位于 GitHub 组织中,请向组织所有者请求管理员级权限。如需详细了解 GitHub 组织,请参阅 GitHub 账号类型。
发起连接
在 Google Cloud 控制台中打开Developer Connect页面。
系统会打开 Git 代码库页面,其中显示了源代码管理提供商的列表。
点击相应提供商卡片上的关联,选择源代码管理提供商。
创建连接页面会打开。
选择
us-central1作为区域。输入
quickstart-connection作为名称。点击继续。
系统会显示 Google Developer Connect 对话框,请求授权以使用您的 GitHub OAuth 令牌。
如果您没有看到对话框,请关闭所有弹出广告拦截浏览器插件,并确保浏览器设置允许弹出式窗口。例如,在 Chrome 中,请按照说明允许弹出式窗口。
点击我了解并继续。
如果系统提示,请完成 GitHub 账号登录步骤。
如果系统提示您授权,请点击授权 Developer Connect。如果您没有看到此提示,则表示此账号已获得授权。
配置连接
按照以下步骤,授予您的 GitHub 账号和代码库的权限。提示取决于使用 GitHub 账号的用户是否已在 GitHub 中安装 Google Developer Connect 应用。
如果您看到 GitHub 账号列表:您尚未安装该应用。请按以下步骤安装和配置该工具:
选择有权访问要关联的代码库的 GitHub 账号。
指定 GitHub 代码库权限并安装应用。如需了解详情,请参阅 GitHub 上有关安装应用的说明。
如果您看到重复使用现有安装的提示:请按照以下步骤选择要在何处安装和配置应用:
点击 GitHub 账号,查看已安装该应用的账号。如果您看到要使用的账号,请选择该账号。
- 点击确认。
如果您未看到要使用的账号,请选择在另一个 GitHub 账号中安装 GitHub 应用。
点击确认。
选择您要使用的 GitHub 账号。
指定 GitHub 代码库权限并安装应用。如需了解详情,请参阅 GitHub 上有关安装应用的说明。
在代码库中,选择要关联的代码库。
点击关联。
相应连接会添加到连接列表中,关联的代码库会添加到代码库列表中。
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
在 Google Cloud 控制台中,前往 Developer Connect 页面。
在代码库标签页中,在包含关联代码库名称的行中,点击 更多选项。
选择解除关联。
点击确认。
点击连接标签页。
在包含连接名称的行中,点击 更多选项。
选择删除。
输入连接的名称。
点击确认。
删除关联和链接不会删除 GitHub.com 上的代码库。如果您为此快速入门创建了新的 GitHub 代码库,并且想要删除该代码库,请按照 GitHub 说明删除代码库。
如果您想卸载 Google Developer Connect 应用,请按照 GitHub 上有关修改已安装应用的说明操作。