Get notified
Hear when a run fails, recovers or ends: on your desktop, in a chat, or any way you like.
You need: a flow. For flows that run by themselves, also the daemon. The daemon
sends notifications for registered flows; for a run in your terminal, add --notify.
1. A desktop notification
Section titled “1. A desktop notification”# in a flow filenotify: desktop: true # tells you when a run fails (the default)| System | What it needs |
|---|---|
| Linux | notify-send (package libnotify-bin or libnotify) and a desktop session |
| macOS | Nothing. It appears in the Notification Center. |
| Windows | Nothing. It appears as a toast. |
2. Slack, Discord or Teams
Section titled “2. Slack, Discord or Teams”The webhook address holds a token, so keep it in the secret store, not in the file:
$ truss secret set SLACK_WEBHOOK # paste the https://hooks.slack.com/... addressnotify: on: [failure, recovered] webhook: url: secret:SLACK_WEBHOOK # the address from the store format: slack # slack | discord | teams | genericgeneric posts JSON that any service can read.
3. Anything else: run a command
Section titled “3. Anything else: run a command”Send an email or a text message, or write to a file:
notify: on: failure run: ./scripts/mail-me.shThe command runs in the project folder and finds the outcome in TRUSS_NOTIFY_FLOW,
TRUSS_NOTIFY_STATUS, TRUSS_NOTIFY_REASON, TRUSS_NOTIFY_RUN_ID, TRUSS_NOTIFY_TRIGGER,
TRUSS_NOTIFY_TITLE and TRUSS_NOTIFY_TEXT.
4. Choose when you are told
Section titled “4. Choose when you are told”on takes one value or a list. The default is failure.
on |
You hear about |
|---|---|
failure |
a failed run, or a scheduled time missed while the daemon was stopped |
success |
every successful run |
recovered |
the first success after a failed run |
changed |
a run that ended differently from the one before |
always |
every run that ran, and missed schedules |
You can use several ways at once: desktop, webhook and run in one notify block.
5. Try it
Section titled “5. Try it”$ truss run backup --notifyrecovered and changed compare with the run before, which only the daemon keeps.
It does not arrive?
Section titled “It does not arrive?”A notification that cannot be sent never changes the result of the run. The reason is printed by
truss run --notify, and written to the daemon log (truss daemon logs) otherwise.
- Linux, no desktop notification: install
libnotify, and run the daemon inside your login session. - No Slack message:
truss secret listshows whether the secret is stored; the address must start withhttps://.
Every key is in the notify reference.