mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: support custom notifications (#19751)
## Description Adds support for sending an ad‑hoc custom notification to the authenticated user via API and CLI. This is useful for surfacing the result of scripts or long‑running tasks. Notifications are delivered through the configured method and the dashboard Inbox, respecting existing preferences and delivery settings. ## Changes * New notification template: “Custom Notification” with a label for a custom title and a custom message. * New API endpoint: `POST /api/v2/notifications/custom` to send a custom notification to the requesting user. * New API endpoint: `GET /notifications/templates/custom` to get custom notification template. * New CLI subcommand: `coder notifications custom <title> <message>` to send a custom notification to the requesting user. * Documentation updates: Add a “Custom notifications” section under Administration > Monitoring > Notifications, including instructions on sending custom notifications and examples of when to use them. Closes: https://github.com/coder/coder/issues/19611
This commit is contained in:
@@ -143,9 +143,11 @@ After setting the required fields above:
|
||||
```text
|
||||
CODER_EMAIL_SMARTHOST=smtp.gmail.com:465
|
||||
CODER_EMAIL_AUTH_USERNAME=<user>@<domain>
|
||||
CODER_EMAIL_AUTH_PASSWORD="<app password created above>"
|
||||
CODER_EMAIL_AUTH_PASSWORD="<app password created above (no spaces)>"
|
||||
```
|
||||
|
||||
**Note:** The `CODER_EMAIL_AUTH_PASSWORD` must be entered without spaces.
|
||||
|
||||
See
|
||||
[this help article from Google](https://support.google.com/a/answer/176600?hl=en)
|
||||
for more options.
|
||||
@@ -261,6 +263,43 @@ Administrators can configure which delivery methods are used for each different
|
||||
You can find this page under
|
||||
`https://$CODER_ACCESS_URL/deployment/notifications?tab=events`.
|
||||
|
||||
## Custom notifications
|
||||
|
||||
Custom notifications let you send an ad‑hoc notification to yourself using the Coder CLI.
|
||||
These are useful for surfacing the result of long-running tasks or important state changes.
|
||||
At this time, custom notifications can only be sent to the user making the request.
|
||||
|
||||
To send a custom notification, execute [`coder notifications custom <title> <message>`](../../../reference/cli/notifications_custom.md).
|
||||
|
||||
<!-- TODO(ssncferreira): Update when sending custom notifications to multiple users/roles is supported.
|
||||
Explain deduplication behaviour for multiple users/roles.
|
||||
See: https://github.com/coder/coder/issues/19768
|
||||
-->
|
||||
**Note:** The recipient is always the requesting user as targeting other users or groups isn’t supported yet.
|
||||
|
||||
### Examples
|
||||
|
||||
- Send yourself a quick update:
|
||||
|
||||
```shell
|
||||
coder templates push -y && coder notifications custom "Template push complete" "Template version uploaded."
|
||||
```
|
||||
|
||||
- Use in a script after a long-running task:
|
||||
|
||||
```shell
|
||||
#!/usr/bin/env bash
|
||||
set -o pipefail
|
||||
|
||||
if make test 2>&1 | tee test_output.log; then
|
||||
coder notifications custom "Tests Succeeded" $'Test results:\n • ✅ success'
|
||||
else
|
||||
failures=$(grep -Po '\d+(?=\s+failures)' test_output.log | tail -n1 || echo 0)
|
||||
coder notifications custom "Tests Failed" $'Test results:\n • ❌ failed ('"$failures"' tests failed)'
|
||||
exit 1
|
||||
fi
|
||||
```
|
||||
|
||||
## Stop sending notifications
|
||||
|
||||
Administrators may wish to stop _all_ notifications across the deployment. We
|
||||
|
||||
Reference in New Issue
Block a user