aftercompletion.adoc 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. [#after-completion]
  2. = Execute after completion
  3. Sometimes you want to execute another command after the main command executes, this is often the case when you want to check the status of the main command, or if you want to send a notification.
  4. [source,yaml]
  5. .`config.yaml`
  6. ----
  7. actions:
  8. - title: Check date and send notification via apprise
  9. icon: date
  10. shell: date
  11. shellAfterCompleted: "apprise -c /config/apprise.yml -t 'Notification: Backup script completed' -b 'The backup script completed with code {{ exitCode}}. The log is: \n {{ output }} '"
  12. ----
  13. When running shellAfterCompleted, you *cannot* use argument values - they are not passed to the command. However the following special arguments are defined;
  14. * `{{ exitCode }}` - The exit code of the previous shell command
  15. * `{{ output }}` - The standard output of the previous shell command
  16. * `{{ .Arguments.ot_executionTrackingId }}` - The unique execution tracking id for this execution (version 3k; in 2k use `{{ ot_executionTrackingId }}`)
  17. * `{{ .Arguments.ot_username }}` - The username of the user who started the execution (version 3k; in 2k use `{{ ot_username }}`). May be `guest` or `cron` for unauthenticated or automated runs.
  18. You can only use a single `shellAfterCompleted`, so use it for notifications, or similar. It would be an antipattern to use this do run 2 commands making up a mini script.
  19. The official OliveTin container images from version 2024.03.24 onwards include the fantastic apprise tool, which makes chat notifications on many protocols very easy.
  20. * https://github.com/caronc/apprise
  21. * https://github.com/caronc/apprise/wiki/config
  22. [source,yaml]
  23. .`/config/apprise.yaml`
  24. ----
  25. urls:
  26. - tgram://bottoken/ChatID
  27. ----
  28. == See Also
  29. * xref:./triggers.adoc[Triggers] - Executing full actions after this one (with separate arguments, etc).