管理推出作業和版本
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
如果啟用自動推出功能,每當您將新修訂版本推送至 GitHub 存放區的正式版分支版本時,App Hosting 就會自動推出新版應用程式。您可以在 Firebase 控制台或 App Hosting GitHub 檢查中查看推出狀態。
此外,App Hosting 也支援手動觸發推出作業,適用於 CI/CD 整合,或任何您想強制推出作業的情況。
查看推出作業
Firebase控制台會提供應用程式所有推出作業的詳細資訊。在 App Hosting 中,選取要查看推出作業的後端「檢視」。後端的「推出」分頁會顯示表格,列出這個後端的所有推出記錄。
每個推出項目都包含 Cloud Build 工作和觸發推出的變更或提交內容的連結,以及作者、建立日期和推出狀態等基本資訊。
- Cloud Build 工作是建構環境,App Hosting 會在其中執行應用程式的建構指令。按一下建構 ID 即可存取 Cloud Build 記錄。
- 「變更」是指觸發推出作業的 GitHub 提交或其他動作。
手動觸發推出作業
如要從 GitHub 來源手動觸發推出作業,但不想推送新的提交內容,可以從 Firebase 控制台或 Firebase CLI 建立推出作業。這項功能在下列情況下非常實用:
- 強制重新產生靜態內容。
- 允許 CI/CD 系統觸發推出程序。
- 將正式版推出時間限制在特定日期或時間。
如要在 Firebase 控制台中觸發發布作業,請按照下列步驟操作:
- 在 App Hosting 中,選取要建立階段發布的後端「檢視」。
- 在後端資訊主頁摘要中,選取「建立推出版本」。
- 選取要部署的分支。
- 選取要部署的修訂版本,可以是最新修訂版本,也可以是您指定修訂版本 ID 的較早修訂版本。
- 選取 [Create] (建立)。推出作業的狀態和建構版本號碼會顯示在推出作業記錄資料表中。推出程序完成後,這個推出版本就會顯示為目前的推出版本。
如要在 Firebase CLI 中觸發發布作業,請執行下列指令,並在系統提示時選取要發布的分支版本:
firebase apphosting:rollouts:create BACKEND_ID
或者,您也可以使用 --git-branch
選項,針對特定分支的最新提交內容啟動推出程序:
firebase apphosting:rollouts:create BACKEND_ID
--git_branch BRANCH_NAME
您也可以使用 --git-commit
選項,以特定提交建立推出作業:
firebase apphosting:rollouts:create BACKEND_ID
--git_commit COMMIT_ID
還原先前的推出作業
App Hosting 提供兩種還原先前發布版本的選項:
建立即時復原作業
有時您可能需要快速還原至舊版應用程式,例如發現新部署的階段推出版本有重大錯誤,或是建構版本不穩定,導致無法進行新的階段推出。在這種情況下,您可以從先前的推出作業還原所選的現有容器映像檔。這個映像檔不會重建,但會使用首次建構時的程式碼和環境設定。
如要建立即時回溯,請按照下列步驟操作:
- 在 App Hosting 中,選取要建立回溯的後端「View」(檢視)。
- 選取「推出」分頁標籤。
- 在後端的「記錄」表格中,選取先前版本的建構三點圖示選單。
- 選取「復原至這個版本」並確認。
重新建構並復原
如要還原舊版應用程式,但仍保留目前的設定,可以在還原程序中重建應用程式。舉例來說,如果最新版本更新了 Secret Manager 中的 API 金鑰值,重建作業可確保應用程式在復原後使用新金鑰。
如要重建及復原:
- 在 App Hosting 中,選取要建立回溯的後端「查看資訊主頁」。\
- 選取「推出」分頁標籤。
- 選取「開始發布」。
- 在「建立推出版本」對話方塊中,勾選「先前的提交」,然後輸入要重建及還原的提交 ID。提交 ID 是「推出記錄」中列出的每個推出作業「變更詳細資料」的一部分,位於標籤的括號內。
- 選取「建立」即可開始回溯。
變更發布設定
如要變更發布的正式版分支,以及啟用或停用自動發布功能,請使用後端資訊主頁的「設定」>「部署」檢視畫面中的控制項。
- 在 App Hosting 中,選取要更新階段發布設定的後端「查看」。
- 在後端資訊主頁中選取「設定」。預設檢視畫面會顯示網域和自訂網域的資訊。
- 選取「Deployment」檢視畫面。在這個檢視畫面中,您可以變更推出作業的正式版分支,以及停用或啟用自動推出功能。此外,您也可以設定應用程式根目錄和後端環境 (請參閱「部署至多個環境」)。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-08 (世界標準時間)。
[null,null,["上次更新時間:2025-08-08 (世界標準時間)。"],[],[],null,["\u003cbr /\u003e\n\nIf you have automatic rollouts enabled, every time you push a new commit to the\nlive branch in your GitHub repository App Hosting automatically rolls out a\nnew version of your app. You can check the rollout status in the\nFirebase console or in the App Hosting GitHub check.\n\nAdditionally, App Hosting supports manually triggered rollouts for\nCI/CD integration or any other case where you want to force a rollout.\n\nView rollouts\n\nThe Firebase console provides access to detailed information about all\nrollouts of your app. In [App Hosting](//console.firebase.google.com/project/_/apphosting), select **View** for\nthe backend whose rollouts you'd like to see. The **Rollouts** tab for the\nbackend displays a table listing a history of all rollouts for this backend.\n\nEach rollout entry contains links to the Cloud Build job and\nthe change or commit that triggered the rollout, along with basic information\nabout the author, creation date, and status of the rollout.\n\n- The Cloud Build job is the build environment where App Hosting runs your app's build command. You can access Cloud Build logs by clicking on the build ID.\n- The **Change** is the GitHub commit or other action that triggered the rollout.\n\nManually trigger a rollout\n\nIf you want to manually trigger a rollout from your GitHub source without\npushing a new commit, you can create a rollout from the Firebase console or\nthe Firebase CLI. This is useful for cases such as:\n\n- Forcing the regeneration of static content.\n- Allowing a CI/CD system to trigger rollouts.\n- Limiting production rollouts to specific dates or times.\n\nTo trigger a rollout in the Firebase console:\n\n1. In [App Hosting](//console.firebase.google.com/project/_/apphosting), select **View** for the backend you want to create a rollout for.\n2. In the backend dashboard summary, select **Create rollout**.\n3. Select the branch to deploy.\n4. Select the commit to deploy, either the latest commit or an earlier commit specified by its commit ID.\n5. Select **Create**. Status and a build number for the rollout is displayed in the rollout history table. When the rollout process is complete, this rollout is displayed as the current rollout.\n\nTo trigger a rollout in the Firebase CLI, run the following command and\nselect the branch for the rollout when prompted: \n\n firebase apphosting:rollouts:create \u003cvar label=\"backend ID\" translate=\"no\"\u003eBACKEND_ID\u003c/var\u003e\n\nAlternatively, you can start a rollout for the latest commit for a specific\nbranch by using the `--git-branch`option: \n\n firebase apphosting:rollouts:create \u003cvar label=\"backend ID\" translate=\"no\"\u003eBACKEND_ID\u003c/var\u003e\n --git_branch \u003cvar label=\"git branch\" translate=\"no\"\u003eBRANCH_NAME\u003c/var\u003e\n\nYou can also create a rollout with a specific commit using the `--git-commit`\noption: \n\n firebase apphosting:rollouts:create \u003cvar label=\"backend ID\" translate=\"no\"\u003eBACKEND_ID\u003c/var\u003e\n --git_commit \u003cvar label=\"git commit\" translate=\"no\"\u003eCOMMIT_ID\u003c/var\u003e\n\nRestore a previous rollout\n\nApp Hosting gives you two options for restoring a previous rollout:\n\n- Roll back instantly without rebuilding\n- Rebuild and roll back to a previous version\n\nCreate an instant rollback\n\nAt times you may need to quickly revert to an older version of your app--for\nexample, if you've discovered a critical bug in a newly deployed rollout or\nyou're experiencing a flaky build that's blocking new rollouts. In such cases\nyou can restore an existing container image of your choice from a previous\nrollout. This image is not rebuilt, but uses the code and environment\nconfiguration from when it was first built.\n\nTo create an instant rollback:\n\n1. In [App Hosting](//console.firebase.google.com/project/_/apphosting), select **View** for the backend you want to create a rollback for.\n2. Select the **Rollouts** tab.\n3. In the **History** table for the backend, select the three-dot menu for a previous build.\n4. Select **Roll back to this build** and confirm.\n\nRebuild and roll back\n\nIf you want to revert to an older version of your app but still keep current\nconfiguration, you can rebuild the app as part of the rollback process. For\nexample, if your most recent version updated an API key value in Secret Manager,\nrebuilding can ensure that the new key is used in your app after rolling back.\n\nTo rebuild and roll back:\n\n1. In [App Hosting](//console.firebase.google.com/project/_/apphosting), select **View dashboard** for the backend you want to create a rollback for.\\\\\n2. Select the **Rollouts** tab.\n3. Select **Create rollout**.\n4. In the **Create a rollout** dialog, check **Earlier commit** and then enter the commit ID for the version you want to rebuild and roll back to. The commit ID is part of the \"Change details\" for each rollout listed in your **Rollout history,** contained in parentheses in the label.\n5. Select **Create** to begin the rollback.\n\nChange rollout settings\n\nYou can change the live branch for rollouts and disable or enable automatic\nrollouts using controls in the **Settings \\\u003e Deployment** view in the dashboard\nfor a backend.\n\n1. In [App Hosting](//console.firebase.google.com/project/_/apphosting), select **View** for the backend where you want to update rollout settings.\n2. In the backend dashboard, select **Settings**. The default view displays information about domains and custom domains.\n3. Select the **Deployment** view. In this view, you can change the live branch for rollouts and disable or enable automatic rollouts. Also, there are options to set the app root directory and the environment for the backend (see [Deploy to multiple environments](/docs/app-hosting/multiple-environments))."]]