Drone plugin for sending Slack notifications. For the usage information and a listing of the available options please take a look at the docs.
Build the binary with the following commands:
go build
Build the Docker image with the following commands:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -tags netgo -o release/linux/amd64/drone-slack
docker build -f docker/Dockerfile.linux.amd64 -t plugins/slack .
The functionality to send messages as PMs to a Slack user using their email as the recipient value requires the use of a Slack Token instead of simple webhook. To use a Slack Token you need to create a Slack App with the appropriate OAuth scope.
- Go to https://api.slack.com/apps/new
- In the New Slack App modal form give the app a name (eg Drone Bot) and select the Slack Workspace you want to use it in
- Go to the OAuth and Permissions page for your app and add the following OAuth Scopes in the Bot Token section:
- chat:write - Used to send messages
- users:read - Used to find recipient Slack User IDs
- users:read.email - Used to look up the recipient by a email address
- (Optional) Go to the Basic Information page and give the app a App Icon (./logo.png in repo), background colour (eg. #2C2D30), Description (eg "Drone is container native CICD platform."). Save your App changes.
- Go to the Basic Information page and Install your app to your workspace
- Go to the OAuth and Permissions page and use the Bot User OAuth Access Token for the SLACK_TOKEN plugin setting in your pipeline.
Execute from the working directory:
docker run --rm \
-e SLACK_TOKEN=https://hooks.slack.com/services/... \
-e PLUGIN_CHANNEL=foo \
-e PLUGIN_USERNAME=drone \
-e DRONE_REPO_OWNER=octocat \
-e DRONE_REPO_NAME=hello-world \
-e DRONE_COMMIT_SHA=7fd1a60b01f91b314f59955a4e4d4e80d8edf11d \
-e DRONE_COMMIT_BRANCH=master \
-e DRONE_COMMIT_AUTHOR=octocat \
-e DRONE_COMMIT_AUTHOR_EMAIL=octocat@github.com \
-e DRONE_COMMIT_AUTHOR_AVATAR="https://avatars0.githubusercontent.com/u/583231?s=460&v=4" \
-e DRONE_COMMIT_AUTHOR_NAME="The Octocat" \
-e DRONE_BUILD_NUMBER=1 \
-e DRONE_BUILD_STATUS=success \
-e DRONE_BUILD_LINK=http://github.com/octocat/hello-world \
-e DRONE_TAG=1.0.0 \
plugins/slack
