Sending Notifications to Slack
Since QuickBuild 15.0.x, it is possible to send notifications to Slack via Slack webhook. It is a better way to send message to Slack via webhook than via Step. The following sections will show you how to configure the integration.
Create Slack App to enable Webhooks
Go to Your Apps page in Slack to create a new app by visiting https://api.slack.com/apps
Select from scratch then fill in your App name and the workspace you want to receive messages:
then press Create App, you can see your App's profile page, then choose Incoming Webhooks there:
now you can add a new webhook to your workspace, choose the channel to post:
and a webhook is created successfully, you can copy the webhook URL for later use:
For more information, you can also refer to the official documentation on Slack:
https://api.slack.com/messaging/webhooks
Set up webhooks in QuickBuild
Now, back to QuickBuild, navigate to the configuration which you want to send build notifications to, then in configuration settings, choose Webhook -> Slack:
paste the URL you copied before from Slack app:
Now, save the setting to use default messages. You can test to see if you can receive the build notifications when the build is triggered:
Customize Notification Message
If you want to use default message, you just need set the message to DEFAULT
, and if you don't want to send message for the specific build event, you can just leave empty for that field. You can also customize the notification message by following the Teams message format.
The custom notification message should be in JSON format, you can send the message as simple as just a single line of text like below:
{
"text": "Hello, World"
}
or you can make your message much fancy and meaningful by using Slack message blocks.
Below is what QuickBuild uses for build finished message:
{
"text": "${title}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "${title}",
"emoji": true
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Build:*\n<${build.getUrl()}|${build.version}>"
},
{
"type": "mrkdwn",
"text": "*Status:*\n${build.status}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Triggered by:*\n${build.getRequesterName()}"
},
{
"type": "mrkdwn",
"text": "*Configuration:*\n${configuration.pathName}"
}
]
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Started at:*\n${beginDate}"
},
{
"type": "mrkdwn",
"text": "*Finished at:*\n${endDate}"
}
]
}
]
}
Just like other scriptable fields in QuickBuild, you can use script in the webhook messages.