-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add possibility to set custom FreeMarker templates for messages
- Loading branch information
Andrei Kliuchnikau
committed
Aug 6, 2024
1 parent
8da9401
commit d4ed89e
Showing
27 changed files
with
376 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
[![ru](https://img.shields.io/badge/lang-ru-red.svg)](https://github.com/qa-guru/allure-notifications/blob/master/README.md) | ||
|
||
# Allure notifications | ||
**Allure notifications** is the library that allows to send automatic notifications about the results of automated tests to your preferred messenger (Telegram, Slack, Skype, Email, Mattermost, Discord, Loop, Rocket.Chat). | ||
|
||
Notification languages: 🇬🇧 🇫🇷 🇷🇺 🇺🇦 🇧🇾 🇨🇳 | ||
|
||
## Content | ||
+ [How it works](#how-it-works) | ||
+ [What the notifications look like](#what-the-notifications-look-like) | ||
+ [How to use in your project](#how-to-use-in-your-project) | ||
|
||
|
||
## How it works | ||
After an autotest has finished its work, the `summary.json` file is generated in the `allure-report/widgets` folder. This file contains general statistic about the test results and uses to form the notification sent by the bot (the diagram is drawn and the corresponding text is added). | ||
|
||
Example of a `summary.json` file | ||
``` | ||
{ | ||
"reportName" : "Allure Report", | ||
"testRuns" : [ ], | ||
"statistic" : { | ||
"failed" : 182, | ||
"broken" : 70, | ||
"skipped" : 118, | ||
"passed" : 439, | ||
"unknown" : 42, | ||
"total" : 851 | ||
}, | ||
"time" : { | ||
"start" : 1590795193703, | ||
"stop" : 1590932641296, | ||
"duration" : 11311, | ||
"minDuration" : 7901, | ||
"maxDuration" : 109870, | ||
"sumDuration" : 150125 | ||
} | ||
} | ||
``` | ||
|
||
## What the notifications look like | ||
Example of a notification in Telegram | ||
|
||
![telegram](https://user-images.githubusercontent.com/109241600/213396660-c70adc4c-7a0f-4926-8d9d-473c6c433dd2.png) | ||
|
||
## How to use in your project | ||
|
||
1. Setup Java | ||
2. Create `notifications` folder in the root of your project | ||
3. Download [the latest version](https://github.com/qa-guru/allure-notifications/releases) of the `allure-notifications-<version>.jar` file and place it in the `notifications` folder in your project | ||
4. In the `notifications` folder create the `config.json` file with the following structure (keep the base section and the messenger to which notifications need to be sent): | ||
``` | ||
{ | ||
"base": { | ||
"logo": "", | ||
"project": "", | ||
"environment": "", | ||
"comment": "", | ||
"reportLink": "", | ||
"language": "ru", | ||
"allureFolder": "", | ||
"enableChart": false, | ||
"templatePath": "" | ||
}, | ||
"telegram": { | ||
"token": "", | ||
"chat": "", | ||
"replyTo": "", | ||
"templatePath": "" | ||
}, | ||
"slack": { | ||
"token": "", | ||
"chat": "", | ||
"replyTo": "", | ||
"templatePath": "" | ||
}, | ||
"mattermost": { | ||
"url": "", | ||
"token": "", | ||
"chat": "", | ||
"templatePath": "" | ||
}, | ||
"rocketChat" : { | ||
"url": "", | ||
"auth_token": "", | ||
"user_id": "", | ||
"channel": "", | ||
"templatePath": "" | ||
}, | ||
"skype": { | ||
"appId": "", | ||
"appSecret": "", | ||
"serviceUrl": "", | ||
"conversationId": "", | ||
"botId": "", | ||
"botName": "", | ||
"templatePath": "" | ||
}, | ||
"mail": { | ||
"host": "", | ||
"port": "", | ||
"username": "", | ||
"password": "", | ||
"securityProtocol": null, | ||
"from": "", | ||
"recipient": "", | ||
"templatePath": "" | ||
}, | ||
"discord": { | ||
"botToken": "", | ||
"channelId": "", | ||
"templatePath": "" | ||
}, | ||
"loop": { | ||
"webhookUrl": "", | ||
"templatePath": "" | ||
}, | ||
"proxy": { | ||
"host": "", | ||
"port": 0, | ||
"username": "", | ||
"password": "" | ||
} | ||
} | ||
``` | ||
The `proxy` block is used if you need to specify additional proxy configuration.\ | ||
Additionally, in any configuration you can specify the `templatePath` parameter to set the path to your own Freemarker template for the message. | ||
``` | ||
{ | ||
"base": { | ||
... | ||
}, | ||
"mail": { | ||
"host": "smtp.gmail.com", | ||
"port": "465", | ||
"username": "username", | ||
"password": "password", | ||
"securityProtocol": "SSL", | ||
"from": "test@gmail.com", | ||
"recipient": "test1@gmail.com", | ||
"templatePath": "templates/html_custom.ftl" | ||
} | ||
} | ||
``` | ||
5. Fill the `base` block in the `config.json` file | ||
|
||
Example: | ||
``` | ||
"base": { | ||
"project": "some project", | ||
"environment": "some env", | ||
"comment": "some comment", | ||
"reportLink": "", | ||
"language": "en", | ||
"allureFolder": "build/allure-report/", | ||
"enableChart": true, | ||
"logo": "logo.png", | ||
"durationFormat": "HH:mm:ss.SSS" | ||
} | ||
``` | ||
|
||
Fields: | ||
+ `project`, `environment`, `comment` - the name of the project, the name of the environment, and a custom comment. | ||
+ `reportLink` - the link to the Allure report with results of tests. | ||
+ `language` - the language in which the notification text will be formed (options: `en` / `fr` / `ru` / `ua` / `by` / `cn`). | ||
+ `allureFolder` - the path to the folder with Allure results. | ||
+ `enableChart` - whether the chart should be displayed (options: `true` / `false`). | ||
+ `logo` - path to the logo file (if filled, the corresponding logo will be displayed in the top left corner of the chart). | ||
+ `durationFormat` (optional, default value is `HH:mm:ss.SSS`) - specifies the desired output format for the test duration. | ||
6. Fill in the `config.json` file block with the information about the chosen messenger. | ||
7. Execute the following command in terminal: | ||
``` | ||
java "-DconfigFile=notifications/config.json" -jar notifications/allure-notifications-4.6.1.jar | ||
``` | ||
Note: | ||
|
||
+ by the time of execution the `summary.json` file should already be generated. | ||
+ in the command-line text you need to specify the version of the `jar` file that you downloaded in the previous steps. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.