SuperAPI AI 工具集

sentry-ci-integration

部署与运维

查看项目

更新于 10-15 23:29

技能介绍

用途:把 Sentry 发布流程接入 CI/CD,使每次部署都自动创建 release、关联提交(suspect commits)、上传 source map 并记录部署环境,从而将错误关联到具体代码并获得可读堆栈。

前置条件:Sentry 账号与项目;SENTRY_AUTH_TOKEN(需 project:releases、org:read 权限);SENTRY_ORG 与 SENTRY_PROJECT;构建时生成 source map;Git 集成用于提交关联;sentry-cli 可通过 npm install -g @sentry/cli、npx @sentry/cli 或 getsentry/sentry-cli 镜像使用。

主要能力与用法:核心五步流水线为 sentry-cli releases new "$VERSION"、releases set-commits "$VERSION" --auto、releases files "$VERSION" upload-sourcemaps ./dist --url-prefix '~/' --validate、releases finalize、releases deploys "$VERSION" new -e production。也可用 getsentry/action-release GitHub Action,或用 @sentry/vite-plugin、@sentry/webpack-plugin、@sentry/esbuild-plugin 在构建中自动上传并可选删除 .map 文件。资料提供 GitHub Actions、GitLab CI、CircleCI 及 monorepo 多项目示例。

限制与注意:--url-prefix 必须匹配 JS 实际访问路径;source map 上传超过 40 MB 会报 413;浅克隆会导致提交关联失败,需 fetch-depth: 0;插件在缺少 token 时静默跳过。文档还列出 401、组织未找到等常见错误的排查方式,但未提供收费与价格信息。