slack plugin

The Slack plugin sends notifications as slack messages by calling a webhook, so that deployment events and other messages can be directed to a slack channel and subscribed to and read by a DevOps team responsible for an application/service.

The Slack plugin can be used in two ways:

  • as a chatops plugin for deployment updates, to send Skopos messages on events like deploy start/finish
  • as a regular plugin invoked during deployment to send user defined notifications.

Of course, it is possible to combine the two and have slack notifications both from Skopos and from the deployment plan be received on the same channel.

Chatops: Skopos notifications

To use as an engine chatops plugin, add chatops_plugin: slack to your environment file. Check the chatops_plugin section of the environment file docs for the list of events that will be sent if this plugin is configured as chatops_plugin.

For example, the target environment file may look like this:

chatops_plugin: slack

plugin_config:
    slack:
        url: 'https://hooks.slack.com/services/F0LFL61HF/L45LUWFM1/NlR6Gi4DMiGaWn3efatnpfsD'

Once Slack is configured as the chatops plugin, Skopos will send important deployment-related notifications to it.

(Make sure the above snippet is either loaded as a separate environment file or is included in an environment file loaded with a project)

Injected step notifications

When using this plugin as a Skopos model "injected step", the following actions are supported:

  • notify - send a notification

The following arguments are supported for the notify action:

  • text - (required) The text of the message
  • fail_on_error - specifies whether a failure to send a notification should cause an error (Default: false)

Examples

Here are a few examples in the Skopos model "injected step" format:

components:
  appsrv:
    ...
    lifecycle:

      post_instance_create:
        steps:
          - call:
              plugin: slack
              action: notify
              label: "Send slack notification"
              arguments:
                text: "Created new appsrv"

The label and message text can include references to substitution variables, including variables defined in the target environment file and special variables that include instance information.

Configuration

This plugin supports the following configuration settings (specified as Plugin Configuration in your environment file):

  • url - (required) The url to the slack incoming webhook to be used when sending notifications. You can create such a webhook for you slack account by visiting this link. Example: "https://hooks.slack.com/services/F0LFL61HF/L45LUWFM1/NlR6Gi4DMiGaWn3efatnpfsD"

Example target environment file:

# comment out the following line if you don't want the Skopos deploy notifications
chatops_plugin: slack

plugin_config:
    slack:
        url: 'https://hooks.slack.com/services/F0LFL61HF/L45LUWFM1/NlR6Gi4DMiGaWn3efatnpfsD'

Note that Slack webhooks include the message sender name, so if you want the sender name to include the project name, you will want to create a separate webhook for each (important) project. Alternatively, you can share the webhook (and even the whole environment file) between multiple projects.