|
1 | 1 | --- |
2 | 2 | title: Configuration |
3 | | -description: Environment variables and configuration options for the Sentry CLI |
| 3 | +description: Environment variables, config files, and configuration options for the Sentry CLI |
4 | 4 | --- |
5 | 5 |
|
6 | | -The Sentry CLI can be configured through environment variables and a local database. Most users don't need to set any of these — the CLI auto-detects your project from your codebase and stores credentials locally after `sentry auth login`. |
| 6 | +The Sentry CLI can be configured through config files, environment variables, and a local database. Most users don't need to set any of these — the CLI auto-detects your project from your codebase and stores credentials locally after `sentry auth login`. |
| 7 | + |
| 8 | +## Configuration File (`.sentryclirc`) |
| 9 | + |
| 10 | +The CLI supports a `.sentryclirc` config file using standard INI syntax. This is the same format used by the legacy `sentry-cli` tool, so existing config files are automatically picked up. |
| 11 | + |
| 12 | +### How It Works |
| 13 | + |
| 14 | +The CLI looks for `.sentryclirc` files by walking up from your current directory toward the filesystem root. If multiple files are found, values from the closest file take priority, with `~/.sentryclirc` serving as a global fallback. |
| 15 | + |
| 16 | +```ini |
| 17 | +[defaults] |
| 18 | +org = my-org |
| 19 | +project = my-project |
| 20 | + |
| 21 | +[auth] |
| 22 | +token = sntrys_... |
| 23 | +``` |
| 24 | + |
| 25 | +### Supported Fields |
| 26 | + |
| 27 | +| Section | Key | Description | |
| 28 | +|---------|-----|-------------| |
| 29 | +| `[defaults]` | `org` | Default organization slug | |
| 30 | +| `[defaults]` | `project` | Default project slug | |
| 31 | +| `[defaults]` | `url` | Sentry base URL (for self-hosted) | |
| 32 | +| `[auth]` | `token` | Auth token (mapped to `SENTRY_AUTH_TOKEN`) | |
| 33 | + |
| 34 | +### Monorepo Setup |
| 35 | + |
| 36 | +In monorepos, place a `.sentryclirc` at the repo root with your org, then add per-package configs with just the project: |
| 37 | + |
| 38 | +``` |
| 39 | +my-monorepo/ |
| 40 | + .sentryclirc # [defaults] org = my-company |
| 41 | + packages/ |
| 42 | + frontend/ |
| 43 | + .sentryclirc # [defaults] project = frontend-web |
| 44 | + backend/ |
| 45 | + .sentryclirc # [defaults] project = backend-api |
| 46 | +``` |
| 47 | + |
| 48 | +When you run a command from `packages/frontend/`, the CLI resolves `org = my-company` from the root and `project = frontend-web` from the closest file. |
| 49 | + |
| 50 | +### Resolution Priority |
| 51 | + |
| 52 | +When the CLI needs to determine your org and project, it checks these sources in order: |
| 53 | + |
| 54 | +1. **Explicit CLI arguments** — `sentry issue list my-org/my-project` |
| 55 | +2. **Environment variables** — `SENTRY_ORG` / `SENTRY_PROJECT` |
| 56 | +3. **`.sentryclirc` config file** — walked up from CWD, merged with `~/.sentryclirc` |
| 57 | +4. **DSN auto-detection** — scans source code and `.env` files |
| 58 | +5. **Directory name inference** — matches your directory name against project slugs |
| 59 | + |
| 60 | +The first source that provides both org and project wins. For org-only commands, only the org is needed. |
| 61 | + |
| 62 | +### Backward Compatibility |
| 63 | + |
| 64 | +If you previously used the legacy `sentry-cli` and have a `~/.sentryclirc` file, the new CLI reads it automatically. The `[defaults]` and `[auth]` sections are fully compatible. The `[auth] token` value is mapped to the `SENTRY_AUTH_TOKEN` environment variable internally (only if the env var is not already set). |
7 | 65 |
|
8 | 66 | ## Environment Variables |
9 | 67 |
|
|
0 commit comments