Skip to content

Commit 64a86b1

Browse files
committed
docs: add environment variable documentation to CLAUDE.md
1 parent 52d5359 commit 64a86b1

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

CLAUDE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ struct Job {
2929
jitter: Option<Duration>, // Random delay before execution (0 to jitter)
3030
log_file: Option<String>, // Path to log file (relative to job dir)
3131
log_max_size: u64, // Max log size before rotation (default: 10M)
32+
env_file: Option<String>, // Path to .env file (relative to job dir)
33+
env: Option<HashMap<String, String>>, // Inline env vars
3234
}
3335

3436
struct RetryConfig {
@@ -38,6 +40,13 @@ struct RetryConfig {
3840
// Auto-inferred as 25% of delay when not set
3941
}
4042

43+
struct RunnerConfig {
44+
timezone: TimezoneConfig,
45+
env_file: Option<String>, // Path to .env file (relative to repo root)
46+
env: Option<HashMap<String, String>>, // Inline env vars
47+
webhook: Vec<WebhookConfig>,
48+
}
49+
4150
// Parsed from rollcron.yaml
4251
struct Config { jobs: HashMap<String, JobConfig> }
4352
struct JobConfig { name: Option<String>, schedule: ScheduleConfig, run, timeout, jitter }
@@ -49,6 +58,9 @@ struct ScheduleConfig { cron: String }
4958
```yaml
5059
runner: # Optional: global settings
5160
timezone: Asia/Tokyo # Optional: IANA name, "inherit" (system), or omit for UTC
61+
env_file: .env # Optional: load env vars from file
62+
env: # Optional: inline env vars
63+
KEY: value
5264

5365
jobs:
5466
<job-id>: # Key = ID (used for directories)
@@ -66,6 +78,9 @@ jobs:
6678
# If omitted, auto-inferred as 25% of delay (e.g., 250ms for 1s delay)
6779
log_file: output.log # Optional: file path for stdout/stderr
6880
log_max_size: 10M # Optional: max size before rotation (default: 10M)
81+
env_file: .env # Optional: load env vars from file (relative to job dir)
82+
env: # Optional: inline env vars
83+
KEY: value
6984
```
7085
7186
## Runtime Directory Layout
@@ -127,6 +142,32 @@ jobs:
127142

128143
**Size format**: `10M` (megabytes), `1G` (gigabytes), `512K` (kilobytes), or bytes
129144

145+
## Environment Variables
146+
147+
Environment variables can be set at runner (global) or job level, via inline definitions or `.env` files.
148+
149+
```yaml
150+
runner:
151+
env_file: .env.global # Loaded from repo root
152+
env:
153+
GLOBAL_VAR: value
154+
155+
jobs:
156+
my-job:
157+
env_file: .env.local # Loaded from job directory
158+
env:
159+
JOB_VAR: value
160+
```
161+
162+
**Priority** (later overrides earlier):
163+
```
164+
host ENV < runner.env_file < runner.env < job.env_file < job.env
165+
```
166+
167+
**Shell expansion**: Values support `~` and `$VAR` / `${VAR}` expansion.
168+
169+
**Security**: `env_file` paths are validated to prevent path traversal (must stay within base directory).
170+
130171
## Constraints
131172
132173
- `cargo build` must pass

0 commit comments

Comments
 (0)