Skip to content

Email configuration

German Malykh edited this page Aug 15, 2022 · 10 revisions

1. Email notification configuration

To receive email notifications, you need to fill in the part of the configuration file referring to sending emails

Configuration template for email notifications:

"mail": 
{  
    "host": "...",
    "port": "...",
    "username": "...",
    "password": "...",
    "securityProtocol": "...",
    "from": "...",
    "recipient": "..."  
}

Next, we will consider setting up email notifications using the Gmail service as an example:

  • "host" - The SMTP server to connect to (For Gmail it is "smtp.gmail.com")

  • "port" - The SMTP server port to connect to (Use 465)

  • "username" - User to authenticate to the SMTP server (Use Gmail name)

  • "password" - User's password for authentication. To generate a password, you need:

    1. Go to https://myaccount.google.com/security
    2. Choose "App Passwords"
  1. In the "Select app" field, select "Mail"
  2. In the "Select device" field, select "Windows computer"
  3. Click the "Generate" button
  1. Add the generated password to the "password" field of the configuration file
  • "securityProtocol": (optional: can be omitted or set to null) - one of the following security protocols:

    • SSL - use SSL to connect (make sure the SSL port is used)
    • STARTTLS - use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands. If the server does not support STARTTLS, the connection continues without the use of TLS
  • "from" - Sender's email (Use Gmail name)

  • "recipient" - Recipient email (In the "recipient" field, you can specify a list of email addresses - [email protected], [email protected], [email protected] ...)

The final configuration will look like this:

"mail": 
{  
    "host": "smtp.gmail.com",
    "port": "465",
    "username": "[email protected]",
    "password": "abcqwertyabc",
    "securityProtocol": "SSL",
    "from": "[email protected]",
    "recipient": "[email protected], [email protected], [email protected]"  
}

2. Adding allure-notifications.jar to your autotests project

3. Configure Jenkins (for example)

java  \
"-Dmessenger=email" \
"-Dmail.host=smtp.gmail.com" \
"-Dmail.port=465" \
"[email protected]" \
"-Dmail.password=12345..." \
"[email protected], [email protected]" \
"-Dproject.name=${JOB_BASE_NAME}" \             <- jenkins environment var
"-Dbuild.launch.name=Some release 2.0" \
"-Dbuild.env=https://prod.your.site" \
"-Dbuild.report.link=${BUILD_URL}" \            <- jenkins environment var
"-Dlang=en" \
"-Denable.chart=true" \
"-Dallure.report.folder=./allure-report/" \
-jar allure-notifications-2.2.1.jar

4. Email notification example

Clone this wiki locally