CI plugin to post messages to Slack or other chat clients with Slack compatible incoming webhooks like Rocket.Chat
The following parameters/secrets can be set to configure the plugin.
- 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}}
The following secret values can be set to configure the plugin.
- SLACK_WEBHOOK - The slack webhook to post the message to
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
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}}
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}}