管理发布和版本
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
如果您已启用自动发布,则每次将新提交推送到 GitHub 代码库中的正式版分支时,App Hosting 都会自动发布应用的新版本。您可以在 Firebase 控制台或 App Hosting GitHub 检查中查看发布状态。
此外,App Hosting 还支持手动触发的发布,以用于 CI/CD 集成或您想要强制执行发布的任何其他情况。
查看发布作业
Firebase 控制台可让您访问有关应用所有发布版本的详细信息。在 App Hosting 中,选择您要查看其发布版本的后端对应的查看。后端的 Rollouts 标签页会显示一个表格,其中列出了相应后端的所有发布历史记录。
每个发布条目都包含指向 Cloud Build 作业和触发发布的更改或提交的链接,以及有关发布作者、创建日期和状态的基本信息。
- Cloud Build 作业是 App Hosting 运行应用 build 命令的 build 环境。您可以点击 build ID 来访问 Cloud Build 日志。
- 更改是指触发发布流程的 GitHub 提交或其他操作。
手动触发发布
如果您想在不推送新提交的情况下从 GitHub 来源手动触发发布,可以通过 Firebase 控制台或 Firebase CLI 创建发布。这在以下情况下非常有用:
- 强制重新生成静态内容。
- 允许 CI/CD 系统触发发布。
- 将生产版本发布限制在特定日期或时间。
如需在 Firebase 控制台中触发发布,请执行以下操作:
- 在 App Hosting 中,选择要为其创建发布的后端的查看。
- 在后端信息中心摘要中,选择创建发布。
- 选择要部署的分支。
- 选择要部署的提交,可以是最新提交,也可以是按提交 ID 指定的较早提交。
- 选择创建。发布历史记录表中会显示发布的状态和 build 编号。发布流程完成后,相应发布会显示为当前发布。
如需在 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
恢复之前的发布
应用托管提供了两种用于恢复之前发布的版本的方式:
创建即时回滚
有时,您可能需要快速恢复到应用的旧版本,例如,如果您在新部署的发布版本中发现了严重 bug,或者遇到了不稳定的 build,导致无法进行新的发布。在这种情况下,您可以从之前的发布中恢复所选的现有容器映像。此映像不会重新构建,而是使用首次构建时的代码和环境配置。
如需创建即时回滚,请执行以下操作:
- 在 App Hosting 中,选择要为其创建回滚的后端的查看。
- 选择发布标签页。
- 在后端的历史记录表格中,选择之前 build 对应的三点状菜单。
- 选择回滚到此 build,然后确认。
重新构建并回滚
如果您想恢复到应用的旧版本,但仍保留当前配置,可以在回滚过程中重新构建应用。例如,如果最新版本更新了 Secret Manager 中的 API 密钥值,重新构建可以确保在回滚后,应用中使用的是新密钥。
如需重新构建并回滚,请执行以下操作:
- 在 App Hosting 中,选择要为其创建回滚的后端的查看信息中心。\
- 选择发布标签页。
- 选择创建发布。
- 在创建发布版本对话框中,选中之前的提交,然后输入要重新构建并回滚到的版本的提交 ID。提交 ID 是发布历史记录中列出的每次发布的“更改详情”的一部分,包含在标签中的英文括号内。
- 选择创建以开始回滚。
更改发布设置
您可以使用后端信息中心内设置 > 部署 视图中的控件更改发布版本的实时分支,以及停用或启用自动发布。
- 在 App Hosting 中,选择要更新分阶段发布设置的后端对应的查看。
- 在后端信息中心内,选择设置。默认视图会显示有关网域和自定义网域的信息。
- 选择部署视图。在此视图中,您可以更改发布所用的正式版分支,以及停用或启用自动发布。此外,您还可以选择设置应用根目录和后端环境(请参阅部署到多个环境)。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-08。
[null,null,["最后更新时间 (UTC):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))."]]