Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Integrating with Slack

In order to receive notifications in Slack about the status of the testing process, Testkube provides integration with Slack. Below are the configuration steps. Click here for a video tutorial.

Step 1 - Install the Testkube bot to Your Slack Workspace

Testkube bot:

Add Testkube bot to your Slack workspace

Once you add Slack bot to your workspace, note the bot token, you will need it in the next step.

Authentification was succesfull!
Please use the following token in the Helm values for slackToken:
xoxb-123456789012-1234567890123-123456789012345678901234

Step 2 - Configure Testkube to Use the Slack bot Token

Populate slackToken in the Helm values or apply it directly with:

helm upgrade \
--install \
--namespace testkube \
--create-namespace \
--set testkube-api.slackToken="YOUR_SLACK_TOKEN" \
kubeshop/testkube

To see all the values that can be configured, check the Helm chart documentation here.

Step 3 - Add the Testkube bot to the Slack Channel

Add the Testkube bot to the Slack channel where you want to receive notifications. Do this by inviting the bot to a specific channel. By default, the Testkube bot will send to the first channel that the Testkube bot is member of. You can update the config in the next step.

Add Testkube bot to Slack channel

Step 4 - (Optional) Adjust Slack Config File

By default, the configuration /charts/testkube-api/slack-config.json looks like below; it will send notifications for all events and all test or test suite names with any labels. If the channel is left empty, it will send to the first channel that the Testkube bot is member of.

It is an array of config objects and can use any config combinations:

config.yaml
- ChannelID: C058AGQ25D2
selector: {}
testName: []
testSuiteName: []
events:
- start-test
- end-test-success
- end-test-failed
- end-test-aborted
- end-test-timeout
- start-testsuite
- end-testsuite-success
- end-testsuite-failed
- end-testsuite-aborted
- end-testsuite-timeout

To apply, pass the file to the Helm values:

helm upgrade \
--install \
--create-namespace \
--namespace testkube \
testkube \
kubeshop/testkube \
--set testkube-api.slackToken="$SLACK_BOT_TOKEN" \
--set testkube-api.slackConfig="$(cat config.yaml)"

For example:

config.yaml
- ChannelID: C01234567
selector:
label1: value1
testName:
- sanity
- testName2
testSuiteName:
- test-suite1
- test-suite2
events:
- end-test-failed
- end-test-timeout
- end-testsuite-failed
- end-testsuite-timeout
- ChannelID: C07654342
selector:
label3: value4
testName:
- integration-test1
- integration-test2
testSuiteName:
- integration-test-suite1
- integration-test-suite2
events:
- start-test
- end-test-success
- end-test-failed
- end-test-aborted
- end-test-timeout
- start-testsuite
- end-testsuite-success
- end-testsuite-failed
- end-testsuite-aborted
- end-testsuite-timeout

This will send notifications to the channel with the id C01234567 for the test and test suites with labels label1:value1 as well as tests with the labels "sanity" and "testName2" and test suites with the labels "test-suite1" and "test-suite2", on events with the labels "end-test-failed", "end-test-timeout", "end-testsuite-failed" and "end-testsuite-timeout", and to the channel with the id C07654342 for tests with labels label3:value4, tests with the labels "integration-test1" and "integration-test2" and test suites with the labels "integration-test-suite1" and "integration-test-suite2" on all events.

Configure the Message Template

The default message is /charts/testkube-api/slack-template.json and is written using Slack block kit builder and Golang templates. You can customize the message depending on your needs. The following structure is referenced in the template to show where the data to show is coming from:

type MessageArgs struct {
ExecutionID string
ExecutionName string
EventType string
Namespace string
Labels string
TestName string
TestType string
Status string
FailedSteps int
TotalSteps int
StartTime string
EndTime string
Duration string
}

Video Tutorial