Slack integration
What is Slack?
Slack is a cloud-based communication platform that provides teams with an organized space for collaboration, enabling users to communicate in real-time, share files and manage projects.
By integrating Slack with Buddy, you can keep your team updated with automatic notifications and updates about your development workflows. This includes notifications about successful or failed builds, deployments and test results, which can be customized with environment variables and block attachments.
You can also use it to trigger and get the status of your pipelines with slash commands.
Image loading...
Setting up Slack integration
The synchronization can be performed in two ways:
Using the official Buddy Slack app (recommended), which:
- can be installed in any Slack workspace
- requires adding a 3rd-party app on self-hosted installations to become available
Using a private Slack app which:
- is restricted to Slack workspaces to which the app creator belongs
- does not require a 3rd-party app on self-hostedinstallations
Buddy Slack app
- Navigate to the Integrations tab and click New integration.
- Look up and click Slack (it can be found under the Notifications category):
Image loading...
- The configuration window will show up. Leave the authorization method at Buddy Slack App:
Image loading...
- Authorize Buddy in the selected Slack workspace:
Image loading...
Private Slack app
This integration requires adding an OAuth token for a bot user that will send messages on behalf of Buddy. To do that, switch the type to Private Slack App and click the Get Token
link. A box with installation instructions will appear:
Image loading...
A. If you already have a Slack application, click Go to Slack's OAuth Apps, copy the Bot User OAuth Token, and paste it to Buddy:
Image loading...
B. If you don't have the application, Buddy will help you create one.
- Click the link in the box to open the Slack API apps page.
- Click Generate Token and copy the Access Token:
Image loading...
- Paste the token to the input in Buddy and click Create private Slack App. This will automatically create an application with all required scopes and settings.
- On the next screen, click Install private app in Slack and install the application to your workspace:
Image loading...
- Copy the newly generated Bot User OAuth Token:
Image loading...
- Switch back to Buddy, close the box, and paste the token to the integration input:
Image loading...
Adding bot to Slack channel
Adding the integration installs a messaging bot to your Slack workspace. The bot has no permissions to private channels and needs to be added manually.
- Right-click on the desired channel and select
View channel details
. - Switch to the Integrations tab and click Add an App.
- You should see Buddy in the list of apps installed in your Slack workspace. Click Add to activate it in your channel:
Image loading...
- Now that Buddy is allowed to send messages, you can add the Slack action to the pipeline:
Image loading...
- In the action details, select the channel where you installed the bot. You can customize the message to your liking using environment variables:
Image loading...
Slash commands
Slash commands are used for ChatOps interactions between Buddy and Slack. To use slash commands, you first need to configure a Slack application that binds the request URL of the pipeline with the desired command:
- Add a new application via the Slack API panel.
- Select From scratch configuration, enter the App Name (e.g. Buddy Slash Commands), and pick your Slack workspace.
- Click Slash Commands in the features and functionality section.
Click Create New Command, fill in the mandatory fields, and save changes to continue. Repeat for all pipelines that you want to serve.
- Command: the name of the command that will trigger the desired operation from Slack. The best idea is to set it to the name of the target pipeline, e.g.
/prod-stage
- Request URL: the unique Slack handle of the target pipeline
- Short description: e.g. "Staging pipeline in Production"
- Command: the name of the command that will trigger the desired operation from Slack. The best idea is to set it to the name of the target pipeline, e.g.
Image loading...
Eventually, you should end up with a list like this:
Image loading...
- When ready, go to Settings ➝ Install app and click Install to Workspace to activate the app in your Slack workspace.
- The last step is adding the app to the Slack channel from which you want to run the commands – just like with the messaging bot.
Once done, you should see the app in the channel details:
Image loading...
Slack handle location
The request URL – also known as Slack handle – is required to identify the pipeline in Buddy. It is unique to every pipeline and can be found in the dropdown options on the pipeline overview:
Image loading...
Supported commands
The [name]
parameter represents the name of the command in the Slack application.
Example: /prod-stage clear run 1c002dd
– clears pipeline cache and runs deployment from revision 1c002dd in pipeline tied to /prod-stage
command.
/[name] status
– displays pipeline status/[name] run
– runs pipeline. Can be used withparams
. Can be used with any revision./[name] approve
– approves waiting pipeline/[name] params a=b c="some text"
– passes parameters to another pipeline/[name] cancel
– cancels pipeline execution (must be in progress)/[name] refresh
– runs pipeline from scratch. Can be used with any revision./[name] retry
– runs execution again (must be terminated or canceled)/[name] clear run
– clears pipeline cache. Can be used withrun
andrefresh
. Can be used with any revision.
For wildcard pipelines, you can send branch, tag, and pull request parameters:
/[name] clear run tag=1.1
/[name] clear run branch=dev
/[name] clear run pullRequest=feature-update
Last modified on Sep 24, 2024