semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

Email alerts not working

Open Hi-Res-Cam opened this issue 2 years ago • 14 comments

Hi, I have some troubles to get the email alerts working.

Semaphore v2.8.53

config.json:

    "email_sender": "xxx@xxx",
    "email_host": "email-smtp.eu-west-1.amazonaws.com",
    "email_port": "587",
    "email_username": "XXX",
    "email_password": "XXX",
    "email_alert": true,
    "email_secure": true,

Enabled "Allow Alerts for this project" Enabled "Send Alerts" for the specific user

Created an ansible script to raise an error:

4:34:41 PM PLAY [Playing with Ansible and Git] ******************************************** 4:34:41 PM TASK [Gathering Facts] ********************************************************* 4:34:41 PM 4:34:41 PM 4:34:48 PM ok: [localhost] 4:34:48 PM 4:34:48 PM TASK [Generate an error] ******************************************************* 4:34:51 PM fatal: [localhost]: FAILED! => {"changed": true, "cmd": "exit 1", "delta": "0:00:00.017528", "end": "2022-08-17 16:34:50.762393", "msg": "non-zero return code", "rc": 1, "start": "2022-08-17 16:34:50.744865", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []} 4:34:51 PM 4:34:51 PM PLAY RECAP ********************************************************************* 4:34:51 PM localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0 4:34:51 PM 4:34:51 PM

Running playbook failed: exit status 2

Started semaphore from CLI to get output:

./semaphore server --config config.json

Getting back only INFO logs, no error, no warnings:

INFO[0573] Set resource locker with TaskRunner 58 INFO[0573] Task 58 removed from queue INFO[0590] Stopped running TaskRunner 58 INFO[0590] Release resource locker with TaskRunner 58

Tested different SMTP ports, added wrong credentials, changed email-host to force an error... nothing happens. Seems like Semaphore does not even try to send an email.

Any idea what is missing?

Hi-Res-Cam avatar Aug 17 '22 14:08 Hi-Res-Cam

@Hi-Res-Cam Did you solved the problem?? I have same issue

YoungjuWang avatar Sep 21 '22 09:09 YoungjuWang

no, the problem still persists

Hi-Res-Cam avatar Sep 21 '22 09:09 Hi-Res-Cam

@fiftin I use semaphore from 'master' branch. and I have same issue. Can you check this issue??

YoungjuWang avatar Sep 22 '22 01:09 YoungjuWang

Fixed in v2.8.67: https://github.com/ansible-semaphore/semaphore/releases/tag/v2.8.67

fiftin avatar Oct 02 '22 18:10 fiftin

Just got this working (was a bit of a run-around when using docker, which I will try to submit a discussion or bug or PR about, TBD).

However, I'm only getting failed alerts, not success alerts. Got a failed email from the bottom job but nothing from the top one run right after it.

image

Suppress success alerts is not currently checked for this job image

config.json

{
        "mysql": {
                "host": "mysql-semaphore:3306",
                "user": "semaphore_user",
                "pass": "******",
                "name": "semaphore_db",
                "options": null
        },
        "bolt": {
                "host": "",
                "user": "",
                "pass": "",
                "name": "",
                "options": null
        },
        "postgres": {
                "host": "",
                "user": "",
                "pass": "",
                "name": "",
                "options": null
        },
        "dialect": "mysql",
        "port": "",
        "interface": "",
        "tmp_path": "/tmp/semaphore",
        "cookie_hash": "******",
        "cookie_encryption": "******",
        "access_key_encryption": "*******",
        "email_sender": "********",
        "email_host": "smtp.gmail.com",
        "email_port": "587",
        "email_username": "***********",
        "email_password": "*******",
        "web_host": "",
        "ldap_binddn": "",
        "ldap_bindpassword": "",
        "ldap_server": "",
        "ldap_searchdn": "",
        "ldap_searchfilter": "",
        "ldap_mappings": {
                "dn": "",
                "mail": "",
                "uid": "",
                "cn": ""
        },
        "telegram_chat": "",
        "telegram_token": "",
        "slack_url": "",
        "max_parallel_tasks": 0,
        "email_alert": true,
        "email_secure": true,
        "telegram_alert": false,
        "slack_alert": false,
        "ldap_enable": false,
        "ldap_needtls": false,
        "ssh_config_path": "",
        "demo_mode": false
 }

bverkron avatar Oct 02 '22 22:10 bverkron

@bverkron Semaphore only send Email when task failed. It's working correctly.

telegram, slack alert only support success alerting.

YoungjuWang avatar Oct 03 '22 01:10 YoungjuWang

@bverkron Semaphore only send Email when task failed. It's working correctly.

telegram, slack alert only support success alerting.

Any specific reason for that? Seems inconsistent and not sure I understand why email doesn't follow the same pattern as telegram and slack.

bverkron avatar Oct 03 '22 01:10 bverkron

Also, is this documented anywhere? I don't see anything about that difference in the doc or the interface.

bverkron avatar Oct 03 '22 01:10 bverkron

Hi @bverkron ,

  1. It can seems inconsistent, but Semaphore works so initially. Email used for critical alerts.
  2. Telegram and Slack used for all alerts, but you can disable success alerts for templates.

fiftin avatar Oct 05 '22 15:10 fiftin

Hi all, I'm using Version v2.8.74 and have exact the same issue.

On Playbook fails, no mails will be send. No erros or something else, no info, that an email will be send.

We are using an smtp relay host, without authentication. Our Config looks like this.

    "email_sender": "ansible@********.dom",
    "email_host": "mail.********.dom",
    "email_port": "25",
    "email_username": "",
    "email_password": "",
    "email_alert": true,
    "email_secure": false,
    
    

project alert and user alert is enabled.

TimUx avatar Nov 14 '22 14:11 TimUx

I have this same issue running Semaphore in Docker containers. I set the config.json value email_alert to true and also turned it on at the project and user levels, but I still do not get email alerts on failure. Oddly enough, when I created a new project, I can get the emails to send, but only the failures.

feedjosiah avatar Jan 17 '23 23:01 feedjosiah

@feedjosiah same things for me. Finally I found the problem. If you add team members to your project and they don't have permission to send alerts. Even if you have the right to do so, You loose this option.

ansible-semaphore-email-alertes Unless you give this right to team members. There you can send alerts again.

Hopes it'll help someone

moshgit avatar Jan 23 '23 13:01 moshgit

@moshgit Thanks, I've added alerts to everyone in the team and it is currently working. 👍 I rebuilt the whole project though, so it's hard to say if that was the solution.

feedjosiah avatar Jan 24 '23 00:01 feedjosiah

Hi all, I'm using Version v2.8.74 and have exact the same issue.

On Playbook fails, no mails will be send. No erros or something else, no info, that an email will be send.

We are using an smtp relay host, without authentication. Our Config looks like this.

    "email_sender": "ansible@********.dom",
    "email_host": "mail.********.dom",
    "email_port": "25",
    "email_username": "",
    "email_password": "",
    "email_alert": true,
    "email_secure": false,

project alert and user alert is enabled.

A similar situation. v2.8.81 Mail logs are empty

kovalewvladimir avatar Mar 16 '23 07:03 kovalewvladimir

@all the best way to find error is to look for logs, run semaphore from a command like this /usr/bin/semaphore server --config /etc/semaphore/config.json

Go to semaphore, Then try to run a fail test task, You will be able to see error in the logs

zainrizvi1997 avatar Apr 01 '24 20:04 zainrizvi1997