Skip to content

SergeBakharev/drone-slack

 
 

Repository files navigation

drone-slack

Build Status Gitter chat Join the discussion at https://discourse.drone.io Drone questions at https://stackoverflow.com Go Doc Go Report

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

Build the binary with the following commands:

go build

Docker

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 .

Slack App Creation

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.

  1. Go to https://api.slack.com/apps/new
  2. 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
  3. 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
  1. (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.
  2. Go to the Basic Information page and Install your app to your workspace
  3. Go to the OAuth and Permissions page and use the Bot User OAuth Access Token for the SLACK_TOKEN plugin setting in your pipeline.

Usage

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

About

Drone plugin for sending Slack notifications

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Go 100.0%