feat: allow cron-entries to set a per-entry MAILTO

The `cron-entries` trigger is now passed `json` as a second argument, and plugins may print each task as a json object on its own line. A task that sets a `mailto` is written to the crontab under a `MAILTO` of its own, and its output is mailed to that address as well as appended to its log file, so plugins such as the datastore plugins can have the output of a specific scheduled task mailed to a specific person.
This commit is contained in:
Jose Diaz-Gonzalez committed 2026-09-30 17:01:25 -04:00
1 parent 33b70abbf1
commit f91b1f7fc7
8 files changed
+474 -62

No files matched your search

+10 -3
View File
@@ -688,8 +688,10 @@ APP="$1"; PROPERTY="$2"
### `cron-entries`
- Description: Allows injecting cron tasks into the written out scheduled cron task list. Each entry is newline delimited, and individual tasks come in the form `$SCHEDULE;$FULL_COMMAND;$ARBITRARY_DATA`. Individual implementations of cron writing can decide whether and how to include these cron tasks. The `ARBITRARY_DATA` includes the log file path for the basic `docker-local` cron implementation.
- Invoked by:
- Arguments: `$DOKKU_SCHEDULER`
When `$CRON_ENTRY_FORMAT` is `json`, each entry may instead be printed as a json object on its own line, with the keys `schedule`, `command`, `log-file` and `mailto`. Only `schedule` and `command` are required. A task with a `mailto` value is written to the crontab under a `MAILTO` of its own rather than the global `MAILTO`, and its output is mailed to that address in addition to being appended to its `log-file`. Json entries and `;` delimited entries may be printed together. Older versions of Dokku do not pass `$CRON_ENTRY_FORMAT`, and fail to write the crontab if a json entry is printed, so a json entry should only be printed when the argument is `json`.
- Invoked by: `dokku cron:list --global`, and when the `dokku` user crontab is written
- Arguments: `$DOKKU_SCHEDULER $CRON_ENTRY_FORMAT`
- Example:
```shell
@@ -699,8 +701,13 @@ set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
DOKKU_SCHEDULER="$1"
CRON_ENTRY_FORMAT="$2"
# TODO
if [[ "$CRON_ENTRY_FORMAT" == "json" ]]; then
echo '{"schedule":"@daily","command":"/usr/local/bin/some-task","log-file":"/var/log/dokku/some-task.log","mailto":"ops@example.com"}'
else
echo "@daily;/usr/local/bin/some-task;/var/log/dokku/some-task.log"
fi
```
### `dependencies`