diff --git a/README.md b/README.md index 67db06d..06868e6 100644 --- a/README.md +++ b/README.md @@ -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. +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: ```bash @@ -283,6 +288,9 @@ docker run -d \ -e WATCHTOWER_NOTIFICATIONS=slack \ -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_CHANNEL=#my-custom-channel \ + -e WATCHTOWER_NOTIFICATION_SLACK_ICON_EMOJI=:whale: \ + -e WATCHTOWER_NOTIFICATION_SLACK_ICON_URL= \ containrrr/watchtower ``` diff --git a/main.go b/main.go index fc853fe..8a34d67 100644 --- a/main.go +++ b/main.go @@ -162,6 +162,21 @@ func main() { EnvVar: "WATCHTOWER_NOTIFICATION_SLACK_IDENTIFIER", 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{ Name: "notification-msteams-hook", Usage: "The MSTeams WebHook URL to send notifications to", diff --git a/notifications/slack.go b/notifications/slack.go index dd44f29..08f8d3b 100644 --- a/notifications/slack.go +++ b/notifications/slack.go @@ -19,6 +19,9 @@ func newSlackNotifier(c *cli.Context, acceptedLogLevels []log.Level) typeNotifie SlackrusHook: slackrus.SlackrusHook{ HookURL: c.GlobalString("notification-slack-hook-url"), 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, }, }