Skip to content

Add Discord - Send Notification step template#1697

Open
Meanski wants to merge 1 commit into
OctopusDeploy:masterfrom
Meanski:seanw/discord-send-notification
Open

Add Discord - Send Notification step template#1697
Meanski wants to merge 1 commit into
OctopusDeploy:masterfrom
Meanski:seanw/discord-send-notification

Conversation

@Meanski

@Meanski Meanski commented Jul 20, 2026

Copy link
Copy Markdown

Background

Adds a new step template, Discord - Send Notification, which posts a message and/or rich embed to a Discord channel via a webhook. There are currently no Discord templates in the library.

Webhooks were chosen deliberately over a Discord application/bot: a notification-only step needs no OAuth, bot token, or server install — users create a webhook in the channel settings and paste its URL into the step. This mirrors the approach of the existing Slack notification templates.

What the step does:

  • Sends plain message content and/or a rich embed (title, description, colour, timestamp).
  • The auto colour option picks green or red based on whether the deployment has an error (Octopus.Deployment.Error), so a single step with a "run always" condition reports the deployment outcome correctly either way.
  • Optionally adds Project / Release / Environment fields to the embed, and links the embed title back to the deployment in Octopus.
  • Suppresses @everyone/role/user mentions by default (via allowed_mentions) so interpolated release notes can't accidentally ping a server; this can be disabled deliberately.
  • Supports posting into a thread or forum post via an optional Thread ID.
  • Posts with ?wait=true and sets the created message's ID as the MessageId output variable for downstream steps.
  • Handles Discord rate limiting (HTTP 429) with retries honouring retry_after, and truncates content/title/description to Discord's limits.

Implementation notes:

  • Bash script; requires curl and either jq or python3 on the worker (falls back from jq to python3 for JSON encoding/parsing).
  • The webhook URL parameter is a Sensitive control type with an empty default; help text recommends binding it to a sensitive project variable.
  • The webhook URL is validated against the Discord webhook URL shape before any request is made.
  • Required parameters are validated with non-zero exit codes on all failure paths, and Discord API errors are surfaced with their code and message.

Results

A new Discord - Send Notification step template under a new discord category.

Before

n/a — new step template; no Discord templates exist in the library today.

After

Verified end-to-end from an Octopus Cloud instance against a real Discord server, for both deployment outcomes.

Success path (green embed):

Sending Discord notification...
  Content : TEST!
  Embed   : Discord Test release 0.0.3 deployed to Development

Notification sent successfully.
  Message ID: ...

Failure path — a deliberately failing first step, with the notification step's condition set to "Always" (red embed, deployment correctly reported as Failed):

== Failed: Step 1: Simulate Failure ==
...
== Success: Step 2: Discord - Send Notification ==
Sending Discord notification...
  Embed   : Discord Test release 0.0.4 deployed to Development
Notification sent successfully.
  Message ID: ...

Also verified: mention suppression, username/avatar overrides, embed detail fields, the deployment link on the embed title, and error handling (invalid webhook token → Discord 401 surfaced with code and message, step fails with a non-zero exit code). Rate-limit retry (429 honouring retry_after) was exercised with a mocked API.

gulp tests passes locally (4 specs, 0 failures).

Pre-requisites

  • Id should be a GUID that is not 00000000-0000-0000-0000-000000000000
    • NOTE If you are modifying an existing step template, please make sure that you do not modify the Id property (updating the Id will break the Library sync functionality in Octopus).
  • Version should be incremented, otherwise the integration with Octopus won't update the step template correctly
  • Parameter names should not start with $
  • Step template parameter names (the ones declared in the JSON, not the script body) should be prefixed with a namespace so that they are less likely to clash with other user-defined variables in Octopus (see this issue). For example, use an abbreviated name of the step template or the category of the step template).
  • LastModifiedBy field must be present, and (optionally) updated with the correct author
  • The best practices documented here have been applied
  • If a new Category has been created:
    • An image with the name {categoryname}.png must be present under the step-templates/logos folder
    • The switch in the humanize function in gulpfile.babel.js must have a case statement corresponding to it

@github-actions

Copy link
Copy Markdown

Review this PR in Hyponome for a side-by-side diff of the step-template JSON and any embedded scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant