|
| 1 | +--- |
| 2 | +title: Actions |
| 3 | +--- |
| 4 | +# Actions |
| 5 | + |
| 6 | +Actions are at the core of Task Badger's alerting. They let you send notifications and |
| 7 | +callouts based on task events — status changes, progress thresholds, or exceeding an |
| 8 | +expected runtime. |
| 9 | + |
| 10 | +Actions are configured in the Task Badger web UI and apply across your tasks, so you no |
| 11 | +longer need to attach alerting to individual tasks in your code. |
| 12 | + |
| 13 | +!!!note "Deprecation" |
| 14 | + Attaching actions to individual tasks via the SDK, CLI, or API is **deprecated** and |
| 15 | + will be removed in a future release. Configure actions in the web UI instead — see |
| 16 | + [Migrating from per-task actions](#migrating-from-per-task-actions). |
| 17 | + |
| 18 | +## How actions work |
| 19 | + |
| 20 | +An action combines two things: |
| 21 | + |
| 22 | +- A **channel** — the reusable destination that delivers the notification (email, web hook). |
| 23 | + Channels are configured once under **Integrations** and can be reused by many actions. |
| 24 | +- A **trigger** — the task event(s) that cause the action to fire. |
| 25 | + |
| 26 | +When a task reaches a trigger point, Task Badger runs the action's channel with the current |
| 27 | +task details. |
| 28 | + |
| 29 | +## Channels |
| 30 | + |
| 31 | +A channel is a reusable destination for notifications. See [Integrations](integrations.md) |
| 32 | +for the available channel types and how to configure them. |
| 33 | + |
| 34 | +## Creating an action |
| 35 | + |
| 36 | +Actions are created in the web UI under **Integrations → Global Actions**. |
| 37 | + |
| 38 | +Each action has the following settings: |
| 39 | + |
| 40 | +| Setting | Description | |
| 41 | +|----------------|--------------------------------------------------------------------------------------| |
| 42 | +| Name | A label to identify the action. | |
| 43 | +| Project filter | Limit the action to a single project. Leave blank to apply to tasks in all projects. | |
| 44 | +| Name filter | A regular expression matched against the task name. Leave blank to match all tasks. | |
| 45 | +| Channel | The [integration](integrations.md) used to deliver the notification. | |
| 46 | +| Trigger | The task event(s) that fire the action — see [Triggers](#triggers). | |
| 47 | + |
| 48 | +Actions can be enabled or disabled at any time without deleting them. |
| 49 | + |
| 50 | +## Triggers |
| 51 | + |
| 52 | +A trigger is a comma-separated list of trigger points. Each trigger point is one of the following: |
| 53 | + |
| 54 | +* A numeric value which is matched against the task `value`. |
| 55 | +* A percentage value which is matched against the task `value_percent`. |
| 56 | +* A task status which is matched against the task `status`. |
| 57 | +* A special value `max_runtime_exceeded` which is matched when the task exceeds its `max_runtime` value. |
| 58 | + |
| 59 | +Numeric and percentage trigger points can also be prefixed with `*/` to indicate that the trigger should |
| 60 | +fire at regular intervals. For example, `*/50%` will fire at 0%, 50% and 100%. |
| 61 | + |
| 62 | +Examples: |
| 63 | + |
| 64 | +| Trigger | Trigger Fire Points | |
| 65 | +|-----------------------|------------------------------------------------------------------------------| |
| 66 | +| `*/30%` | When `value_percent` passes any multiple of 30%: 0%, 30%, 60%, 90% | |
| 67 | +| `success,error,stale` | When the state changes to any of the listed states | |
| 68 | +| `95%,250,error` | At 95%, when the value reaches or passes 250, when the state becomes `error` | |
| 69 | + |
| 70 | +### Trigger edge cases |
| 71 | + |
| 72 | +If a task value or status skips past multiple trigger points, only the last matching trigger will be |
| 73 | +executed. |
| 74 | + |
| 75 | +For example, an action configured with `20,40,80` whose value goes from `0` directly to `90` will |
| 76 | +skip over the `20` and `40` events and only fire the `80` event. This also applies to task |
| 77 | +status triggers. |
| 78 | + |
| 79 | +This also applies to multiple trigger points that are reached simultaneously, for example, let's say |
| 80 | +an action has the following trigger: `100,success`. It is quite likely that the task could reach |
| 81 | +both those states at the same time but the action will only fire once. |
| 82 | + |
| 83 | +## Migrating from per-task actions |
| 84 | + |
| 85 | +Previously, actions were attached to individual tasks when they were created — via the |
| 86 | +`actions` argument in the SDK, the `--action` option in the CLI, or the task `actions` field |
| 87 | +in the API. This approach is **deprecated**: existing per-task actions keep working for now, |
| 88 | +but the ability to create them will be removed in a future release. |
| 89 | + |
| 90 | +To migrate, recreate your alerting as global actions in the web UI: |
| 91 | + |
| 92 | +1. Configure the channels you need under **Integrations** (see [Integrations](integrations.md)). |
| 93 | +2. Under **Integrations → Global Actions**, create an action for each alert you want, using a |
| 94 | + name filter and/or project filter to target the same tasks you previously attached actions to. |
| 95 | + |
| 96 | +Global actions replace per-task actions entirely — a single action with a name filter can cover |
| 97 | +every task that used to carry an inline action definition. |
0 commit comments