# Scheduler

This directory contains scheduled jobs that run on Jenkins Scheduler for automated tasks.

## Changing the job

The changes apply to the job in Jenkins when the job is actually triggered there.
That means that all the changes to the code of the job will be pulled before execution,
but the change to the schedule (cron) will not. The cron schedule will change the next time the job is triggered.

## Jobs

### `upgrade_pending_prereleases/`

- **Schedule**: Every 30 minutes (`H/30 * * * *`)
- **Purpose**: Automatically upgrades prereleases that have reached their release date to live pages
- **Endpoints**:
  - QA: `https://api-staging.songwhip.com/v3/prereleases/upgrade`
  - PROD: `https://api.songwhip.com/v3/prereleases/upgrade`
- **Implementation**: Uses `run.sh` script with simple curl request and basic error handling. Runs QA and PROD sequentially.
- **Slack notifications**: Configured for failures (#songwhip-dev-alerts)

### `emails_for_incomplete_presaves/`

- **Schedule**: Daily at midnight (`H 0 * * *`)
- **Purpose**: Sends email notifications for incomplete prereleases in both albums and prereleases tables
- **Endpoints**:
  - QA Albums: `https://api-staging.songwhip.com/v3/albums/send-notifications`
  - QA Prereleases: `https://api-staging.songwhip.com/v3/prereleases/send-notifications`
  - PROD Albums: `https://api.songwhip.com/v3/albums/send-notifications`
  - PROD Prereleases: `https://api.songwhip.com/v3/prereleases/send-notifications`
- **Implementation**: Uses inline retry logic with exponential backoff. Runs both albums and prereleases endpoints in parallel for each environment (QA/PROD).
- **Slack notifications**: Not configured

## Configuration

All jobs use:

- AWS role-based authentication
- Shared Jenkins libraries
- Retry logic with exponential backoff (3 attempts, 30s timeout)
- Sequential execution across environments (QA first, then PROD)
