連結原始碼存放區
透過 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 Repositories」(Git 存放區) 頁面隨即開啟,並顯示原始碼管理供應商清單。
按一下該供應商資訊卡上的「連結」,選取原始碼管理服務供應商。
「建立連線」頁面隨即開啟。
選擇
us-central1做為區域。輸入
quickstart-connection做為名稱。按一下「繼續」。
系統會顯示「Google Developer Connect」對話方塊,要求授權使用您的 GitHub OAuth 權杖。
如果沒有看到對話方塊,請關閉所有封鎖彈出式視窗的瀏覽器外掛程式,並確認瀏覽器設定允許彈出式視窗。舉例來說,在 Chrome 中,請按照指示允許彈出式視窗。
按一下「我瞭解並繼續」。
如果系統提示,請完成 GitHub 帳戶登入步驟。
如果系統提示,請按一下「授權開發人員連結」。如果沒有看到這項提示,表示您已授權這個帳戶。
設定連線
按照下列步驟,授予 GitHub 帳戶和存放區的權限。提示取決於 GitHub 帳戶使用者是否已在 GitHub 中安裝 Google Developer Connect 應用程式。
如果看到 GitHub 帳戶清單:表示您尚未安裝應用程式。請按照下列步驟安裝及設定:
選擇有權存取要連結存放區的 GitHub 帳戶。
指定 GitHub 存放區權限並安裝應用程式。詳情請參閱 GitHub 的應用程式安裝說明。
如果系統提示您重複使用現有安裝項目:請按照下列步驟選擇應用程式的安裝位置並進行設定:
按一下「GitHub 帳戶」,即可查看已安裝應用程式的帳戶。如果畫面上顯示要使用的帳戶,請選取該帳戶。
- 按一下「確認」。
如果沒有看到要使用的帳戶,請選擇「將 GitHub 應用程式安裝至其他 GitHub 帳戶」。
按一下「確認」。
選擇要使用的 GitHub 帳戶。
指定 GitHub 存放區權限並安裝應用程式。詳情請參閱 GitHub 的應用程式安裝說明。
在「Repositories」中,選擇要連結的存放區。
按一下「Link」(連結)。
連線會新增至連線清單,連結的存放區則會新增至存放區清單。
清除所用資源
為了避免系統向您的 Google Cloud 帳戶收取本頁面所用資源的費用,請按照下列步驟操作。
前往 Google Cloud 控制台的「Developer Connect」頁面。
在「Repositories」(存放區) 分頁中,按一下含有連結存放區名稱的列,然後點選「More options」(更多選項) 。
選擇「取消連結」。
按一下「確認」。
按一下「連結」分頁標籤。
在連線名稱所在的資料列中,按一下「更多選項」。
選擇 [刪除]。
輸入連線名稱。
按一下「確認」。
刪除連線和連結不會刪除 GitHub.com 上的存放區。如果您為這項快速入門導覽課程建立了新的 GitHub 存放區,並想刪除該存放區,請按照 GitHub 的指示刪除存放區。
如要解除安裝 Google Developer Connect 應用程式,請按照 GitHub 修改已安裝應用程式的操作說明進行。