mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-21 21:30:48 +02:00
Add Slack Channel, IconEmoji, and IconURL options (#241)
This commit is contained in:
parent
ebb416819c
commit
da41afc1d7
3 changed files with 26 additions and 0 deletions
|
@ -274,6 +274,11 @@ Additionally, you should set the Slack webhook url using the `--notification-sla
|
||||||
|
|
||||||
By default, watchtower will send messages under the name `watchtower`, you can customize this string through the `--notification-slack-identifier` option or the `WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER` environment variable.
|
By default, watchtower will send messages under the name `watchtower`, you can customize this string through the `--notification-slack-identifier` option or the `WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER` environment variable.
|
||||||
|
|
||||||
|
Other, optional, variables include:
|
||||||
|
- `--notification-slack-channel` (env. `WATCHTOWER_NOTIFICATION_SLACK_CHANNEL`): A string which overrides the webhook's default channel. Example: #my-custom-channel.
|
||||||
|
- `--notification-slack-icon-emoji` (env. `WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI`): An [emoji code](https://www.webpagefx.com/tools/emoji-cheat-sheet/) string to use in place of the default icon.
|
||||||
|
- `--notification-slack-icon-url` (env. `WATCHTOWER_NOTIFICATION_SLACK_ICON_URL`): An icon image URL string to use in place of the default icon.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -283,6 +288,9 @@ docker run -d \
|
||||||
-e WATCHTOWER_NOTIFICATIONS=slack \
|
-e WATCHTOWER_NOTIFICATIONS=slack \
|
||||||
-e WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL="https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy" \
|
-e WATCHTOWER_NOTIFICATION_SLACK_HOOK_URL="https://hooks.slack.com/services/xxx/yyyyyyyyyyyyyyy" \
|
||||||
-e WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=watchtower-server-1 \
|
-e WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER=watchtower-server-1 \
|
||||||
|
-e WATCHTOWER_NOTIFICATION_SLACK_CHANNEL=#my-custom-channel \
|
||||||
|
-e WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI=:whale: \
|
||||||
|
-e WATCHTOWER_NOTIFICATION_SLACK_ICON_URL=<icon url> \
|
||||||
containrrr/watchtower
|
containrrr/watchtower
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
15
main.go
15
main.go
|
@ -162,6 +162,21 @@ func main() {
|
||||||
EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER",
|
EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER",
|
||||||
Value: "watchtower",
|
Value: "watchtower",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "notification-slack-channel",
|
||||||
|
Usage: "A string which overrides the webhook's default channel. Example: #my-custom-channel",
|
||||||
|
EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_CHANNEL",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "notification-slack-icon-emoji",
|
||||||
|
Usage: "An emoji code string to use in place of the default icon",
|
||||||
|
EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI",
|
||||||
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "notification-slack-icon-url",
|
||||||
|
Usage: "An icon image URL string to use in place of the default icon",
|
||||||
|
EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_ICON_URL",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "notification-msteams-hook",
|
Name: "notification-msteams-hook",
|
||||||
Usage: "The MSTeams WebHook URL to send notifications to",
|
Usage: "The MSTeams WebHook URL to send notifications to",
|
||||||
|
|
|
@ -19,6 +19,9 @@ func newSlackNotifier(c *cli.Context, acceptedLogLevels []log.Level) typeNotifie
|
||||||
SlackrusHook: slackrus.SlackrusHook{
|
SlackrusHook: slackrus.SlackrusHook{
|
||||||
HookURL: c.GlobalString("notification-slack-hook-url"),
|
HookURL: c.GlobalString("notification-slack-hook-url"),
|
||||||
Username: c.GlobalString("notification-slack-identifier"),
|
Username: c.GlobalString("notification-slack-identifier"),
|
||||||
|
Channel: c.GlobalString("notification-slack-channel"),
|
||||||
|
IconEmoji: c.GlobalString("notification-slack-icon-emoji"),
|
||||||
|
IconURL: c.GlobalString("notification-slack-icon-url"),
|
||||||
AcceptedLevels: acceptedLogLevels,
|
AcceptedLevels: acceptedLogLevels,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue