Skip to content

devatherock/simple-slack

Repository files navigation

CircleCI Version Coverage Status Quality Gate Docker Pulls Lines of Code Docker Image Size

simple-slack

CI plugin to post messages to Slack or other chat clients with Slack compatible incoming webhooks like Rocket.Chat

Config

The following parameters/secrets can be set to configure the plugin.

Parameters

  • color - Color in which the message block will be highlighted.
  • text - The message content. The text uses go templating. Any environment variable available at runtime can be used within the text, after converting it to camel case. For example, to use the environment variable DRONE_BUILD_STATUS, the syntax will be {{.DroneBuildStatus}}

Secrets

The following secret values can be set to configure the plugin.

  • SLACK_WEBHOOK - The slack webhook to post the message to

Usage

Docker:

Execute from the working directory:

docker run --rm \
  -e SLACK_WEBHOOK=https://hooks.slack.com/services/... \
  -e PARAMETER_COLOR=#33ad7f \
  -e PARAMETER_TEXT="Success: {{.BuildLink}} ({{.BuildRef}}) by {{.BuildAuthor}}" \
  -e PARAMETER_CHANNEL="xyz" \
  -e PARAMETER_TITLE="Build completed" \
  -e BUILD_REF="refs/heads/master" \
  -e BUILD_AUTHOR=octocat \
  -e BUILD_LINK=http://github.com/octocat/hello-world \
  devatherock/simple-slack:latest

Drone:

pipeline:
  notify_slack:
    when:
      event: [ push ]
      status: [ success, failure, error ]
    image: devatherock/simple-slack:latest
    secrets: [ slack_webhook ]
    settings:
      color: "#33ad7f"
      text: |-
        {{.DroneBuildStatus}} {{.DroneBuildLink}} ({{.DroneCommitRef}}) by {{DroneCommitAuthor}}
        {{.DroneCommitMessage}}

Vela:

steps:
  - name: notify_slack
    ruleset:
      event: [ push ]
      status: [ success ]
    image: devatherock/simple-slack:latest
    secrets: [ slack_webhook ]
    parameters:
      color: "#33ad7f"
      text: |-
        Success: {{.BuildLink}} ({{.BuildRef}}) by {{.BuildAuthor}}
        {{.BuildMessage}}