slackspinnaker

Configure Slack alerts in Spinnaker


When a spinnaker pipeline fails, we can see the following:

Spinnaker Alerts Bot APP [3:24 PM]
Stage failed for APP_NAME
Stage STAGE_NAME for APP_NAME's PIPELINE_NAME has failed

OTHER STUFF FROM NOTIFICATION CONFIG PANEL OF STAGE

Spinnaker   Today at 3:24 PM

It's easy to configure the "OTHER STUFF", but what about the first 3 lines, not seeing a place in Spinnaker UI to do this, perhaps in the configuration files on server?


Solution

  • Here is an update for more recent version of spinnaker, 1.16.5: the custom message is editable for each notification type (start, fail, done). Doesn't seem that you can put html in it, but you can put markup. I don't know at what version of spinnaker the contents of this post got implemented, I just know it holds for 1.16.5.

    Also once you have configured one of your pipelines to use Notification, you can copy the JSON for the notification to other pipelines to easily configure them identically (or as a starting point).

    So I have the following JSON for our Slack notifications, notice the pipeline parameters used and their bold markup:

      "notifications": [
        {
          "address": "spinnaker-notifications",
          "level": "pipeline",
          "message": {
            "pipeline.failed": {
              "text": "SERVICE_NAME: *${ parameters['SERVICE_NAME'] }*\nSERVICE_VERSION: *${ parameters['SERVICE_VERSION'] }*"
            },
            "pipeline.starting": {
              "text": "SERVICE_NAME: *${ parameters['SERVICE_NAME'] }*\nSERVICE_VERSION: ${ parameters['SERVICE_VERSION'] }"
            }
          },
          "type": "slack",
          "when": [
            "pipeline.failed"
          ]
        }
      ],
    

    The message text is easy to configure via the Notifications dialog, just the JSON contains the embedded \n etc.