我們可以使用官方 sentry-cli 工具操作 Sentry API,從而來為你的專案管理一些資料。它主要用於管理 iOSAndroid 的除錯資訊檔案,以及其他平臺的版本(release)和原始碼對映(source maps)管理。

安裝

Docker 映象

預設情況下,該命令在 /work 目錄中執行。掛載相關的你的專案資料夾並在那裡構建輸出以允許 sentry-cli 掃描資源:

# 拉取映象
docker pull getsentry/sentry-cli
# 執行命令
docker run --rm -v $(pwd):/work getsentry/sentry-cli --help
# sentry-cli 1.68.0 # Command line utility for Sentry. # This tool helps you manage remote resources on a Sentry server like
# sourcemaps, debug symbols or releases. Use `--help` on the subcommands
# to learn more about them. # USAGE:
# sentry-cli <SUBCOMMAND> # OPTIONS:
# --api-key <API_KEY>
# The given Sentry API key. # --auth-token <AUTH_TOKEN>
# Use the given Sentry auth token. # -h, --help
# Print this help message. # --log-level <LOG_LEVEL>
# Set the log output verbosity. [possible values: trace, debug, info, warn, error] # --url <URL>
# Fully qualified URL to the Sentry server.
# [defaults to https://sentry.io/]
# -V, --version
# Print version information. # SUBCOMMANDS:
# bash-hook Prints out a bash script that does error handling.
# difutil Locate or analyze debug information files.
# help Prints this message or the help of the given subcommand(s)
# info Print information about the Sentry server.
# issues Manage issues in Sentry.
# login Authenticate with the Sentry server.
# projects Manage projects on Sentry.
# react-native Upload build artifacts for react-native projects.
# releases Manage releases on Sentry.
# repos Manage repositories on Sentry.
# send-event Send a manual event to Sentry.
# upload-dif Upload debugging information files.
# upload-proguard Upload ProGuard mapping files to a project.

配置和認證

配置檔案

sentry-cli 工具可以使用名為 .sentryclirc 的配置檔案以及環境變數和 .env 檔案進行配置。 從當前路徑向上查詢配置檔案,並且始終載入 ~/.sentryclirc 中的預設值。 您還可以從命令列引數覆蓋這些設定。

.sentryclirc

[auth]
token=your-auth-token [defaults]
org=sentry
project=react-sentry-demo
url=https://x.xxx.com

進入容器內

建立一個新版本:

docker run --rm -it -v $(pwd):/work getsentry/sentry-cli /bin/sh

sentry-cli releases new 1.0.0

Refs

公眾號:黑客下午茶