Integrating with Slack
Using Webhooks is the preferred way to integrate Testkube with Slack - Read More. This approach has been deprecated.
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
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.
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:
- ChannelID: C058AGQ25D2
selector: {}
testName: []
testSuiteName: []
testWorkflowName: []
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
- start-testworkflow
- queue-testworkflow
- end-testworkflow-success
- end-testworkflow-failed
- end-testworkflow-aborted
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:
- ChannelID: C01234567
selector:
label1: value1
testName:
- sanity
- testName2
testSuiteName:
- test-suite1
- test-suite2
tesrWorkflowName:
- test-workflow1
- test-workflow2
events:
- end-test-failed
- end-test-timeout
- end-testsuite-failed
- end-testsuite-timeout
- end-testworkflow-failed
- ChannelID: C07654342
selector:
label3: value4
testName:
- integration-test1
- integration-test2
testSuiteName:
- integration-test-suite1
- integration-test-suite2
testWorkflowName:
- integration-test-workflow1
- integration-test-workflow2
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
- start-testworkflow
- queue-testworkflow
- end-testworkflow-success
- end-testworkflow-failed
- end-testworkflow-aborted
This will send notifications to the channel with the id C01234567
for the test, test suites and test workflows with labels label1:value1
as well as tests with the names "sanity" and "testName2", test suites with the names "test-suite1" and "test-suite2" and test workflows with the names "test-workflow1" and "test-workflow2", on events with the labels "end-test-failed", "end-test-timeout", "end-testsuite-failed", "end-testsuite-timeout" and "end-testworkflow-failed", and to the channel with the id C07654342
for tests with labels label3:value4
, tests with the names "integration-test1" and "integration-test2", test suites with the names "integration-test-suite1" and "integration-test-suite2" and test workflows with the names "integration-test-workflow1" and "integration-test-workflow2" 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
}