Jaypore CI

> Jaypore CI: Minimal, Offline, Local CI system.
Log | Files | Refs | README | LICENSE

README.md (1341B)


      1 # 08 — Mail on failure
      2 
      3 Send an email whenever a scheduled CI run fails.
      4 
      5 ## What it does
      6 
      7 A cron entry (`0 0 * * *`) triggers `run.sh` once a day at midnight.
      8 The script runs `python3 manage.py test core` and, only when the tests
      9 fail, sends an email containing:
     10 
     11 - repository name
     12 - commit hash
     13 - timestamp
     14 - the tail of the test output
     15 
     16 Test output is always saved to `$JCI_OUTPUT_DIR/test-output.txt` so you
     17 can inspect it later regardless of pass/fail.
     18 
     19 ## Required environment variables
     20 
     21 | Variable | Purpose |
     22 |---|---|
     23 | `SMTP_HOST` | SMTP server hostname (e.g. `smtp.mailgun.org`) |
     24 | `SMTP_PORT` | SMTP port, typically `587` for STARTTLS |
     25 | `SMTP_USER` | SMTP login username |
     26 | `SMTP_PASS` | SMTP login password or API key |
     27 | `MAIL_FROM` | Sender address (e.g. `ci@example.com`) |
     28 | `MAIL_TO` | Recipient address |
     29 
     30 Set these in your CI environment or in a `.env` file that your Jaypore CI
     31 setup sources before running the pipeline.
     32 
     33 ## How it works
     34 
     35 1. `run.sh` changes into `$JCI_REPO_ROOT` and runs the Django test suite.
     36 2. Output is piped to both stdout and `$JCI_OUTPUT_DIR/test-output.txt`.
     37 3. If the exit code is non-zero, a `send_mail()` helper uses Python's
     38    `smtplib` to deliver a failure report over SMTP/STARTTLS.
     39 4. The script exits with the original test exit code so Jaypore CI
     40    records the run as failed.