How to Setup Slack and Drone Slack Blame
Slack now has deprecated legacy tokens, instead, Slack encourages us to create Slack Apps
to do our job, so I created a note to record how I set up Slack app and use it on drone-slack-blame
plugin.
Create a app: https://api.slack.com/apps?new_app=1
Add features and functionality
Edit App display name
Go to OAuth & Permission, then edit the scope of bots:
What I need is to make Drone (drone-slack-blame) to notify the users with the build status, and send messages to channels as well, so I need
users:read
permission to map Github users and Slack users (you can setmapping
in drone-slack-blame section in drone.yml), and Drone Bot requireschat:write
to send private messages, andchat:write:public
to send messages to public channels.Install App to workspace
then you should see
Bot User OAuth Access Token
is present.Now you can use the token in Drone, here is the example of my drone setting:
Remember to set user mappings, first argument is your GitHub name, and the second one is Slack display name. You can check more in the source code.
How it works?
The image below is for private messages:
And it sends message to a public channel as well:
Last but not least, you can check https://api.slack.com/apps/ to configure your Slack app, I have to say that Slack administration pages are like a huge maze… it always takes me some time to find out what I want.