Sending notifications to Slack
Task
We want to be notified via Slack channel when some events happen in Allure TestOps.
Yes, it's possible
Events based notifications are done by using an outgoing webhook which you can configure for each project individually.
The flow
To send notifications to a Slack channel you need to pass the following steps.
- Create a new application is Slack.
- Create a new channel or designate an existing channel for the notifications.
- Allow application using the incoming webhooks.
- Get the incoming webhook string from Slack.
- Create a new webhook in Allure TestOps project.
- Configure the events for triggering of the outgoing webhook in Allure TestOps.
The next sections will describe the steps defined above.
Setting up an App in Slack
In Allure TestOps webhooks send messages using POST requests with JSON object as a request body. In Slack, such requests are handled by so-called Apps entities.
So, to make webhooks work, you need to create:
- An App.
- A channel where this created App will post messages
Creating a Channel
If in your Slack workspace you don't have a channel that will receive notifications from Allure TestOps, you need to create one.
Go to your Slack workspace, and under the list of Channels, click Add channel. In the channel template selection screen, keep the default option (Blank channel) and click Next:
Enter the channel name and visibility, then click Create.
Creating an App
To create an App, go to Your Apps and click Create New App:
Enter the App name.
Click Create App
The App settings page will open. In the left menu, select Features → Incoming Webhooks and enable the Activate Incoming Webhooks toggle.
Then click Add New Webhook to Workspace at the bottom of the page:
Select the name of the channel the App will send messages to and click Allow.
Click Copy next to the generated webhook URL to copy it to the clipboard. Save it for the next steps.
You’ll need this address for the next step – TestOps will send HTTP requests using this URL.
Configuring the Webhook in TestOps
To continue in Allure TestOps you need to be a project owner.
We now have a Slack App ready to receive POST requests from TestOps. All that’s left is to configure the webhook in Allure TestOps.
Open your Allure TestOps project, go to Settings → Webhooks, and click + Webhook.
The webhook editing panel will open. Enter a name for the webhook (for example, “Slack notifications”).
In the Endpoint field, enter the webhook URL you saved from Slack.
Allure TestOps can send messages related to launches, defects, and test plans. Click Trigger for the desired event type:
The following event types are available:
- Launch creation or closure
- Defect creation, deletion, or closure
- Test plan creation or deletion
Editing the Request
After selecting a trigger, a text field will appear where you can edit the JSON object sent by the webhook. By default, for the launch creation event, the following template is suggested:
{
"text": "Launch {{launchName}}, {{launchUrl}}, opened by {{createdBy}} in the project {{projectName}}"
}
In quotes after "text"
is the message that will appear in the messenger.
You can add variables inside curly braces to the message body (for example, instead of {{launchName}}
the message will display the launch name). This way, you can inform the team about the number of failed tests ({{failedCount}}
) or broken tests ({{brokenCount}}
) in the launch.
Variables can be added manually or by using the { } button:
The full list of variables is available in the TestOps documentation page.
You can completely change the JSON object structure:
{
"user": "{{ createdBy }}",
"date": "{{ createdDate }}",
"text": "{{ launchName }} created"
}
Or not use JSON at all:
{{ launchName }} closed by {{ closedBy }}
If you need to add additional headers to the POST request, click + Header:
Editing the request allows you to ensure proper interaction with external systems and make the message more expressive and useful.
Filters
For launches, you can set filters that will only allow messages for specific events:
Filters can be created:
- for launch names;
- for tags;
- for environment variables (for example, browser or device).
This allows you to receive information only about important launches, filtering by keywords in names or tags.
In the input line, you can combine filters regardless of type. When specifying several criteria of the same type, the message will be sent if at least one criterion (or) is met. When specifying several criteria of different types, the message will be sent if all criteria (and) are met.
Finalizing the Setup
To check if the webhook is configured correctly, click the Test button on the trigger panel — a test message will be sent to the specified Slack channel:
If everything works, click Create. TestOps will now send the configured messages.