Skip to content

Conversation

@fmotalleb
Copy link

@fmotalleb fmotalleb commented Dec 2, 2024

This pull request introduces a non-breaking change and follows #2601, including its changes.

Summary of Changes

  • Added support for webhooks to enhance the alerting system in the Ansible GUI integrated with Semaphore.
  • Added proxy support for messenger alerts
  • Added support for custom telegram api url

This is not a breaking update, but it introduces 4 additional configuration items.

New Configuration Options

AlertWebHookAddress    string    `json:"alert_webhook_address,omitempty" env:"SEMAPHORE_ALERT_WEBHOOK_ADDRESS"`
AlertWebHookHeaders    map[string]string    `json:"alert_webhook_headers,omitempty" env:"SEMAPHORE_ALERT_WEBHOOK_HEADERS"`

TelegramApiUrl    string    `json:"telegram_api_url,omitempty" env:"SEMAPHORE_TELEGRAM_API_URL"`

MessengerProxy    string    `json:"messenger_proxy,omitempty" env:"SEMAPHORE_MESSENGER_PROXY"`

Please review the updates, and let me know if further adjustments are needed.

@fmotalleb fmotalleb changed the title Feat(alerts): webhook alert Feat(alerts): webhook alert + messenger proxy support Dec 2, 2024
@anardil
Copy link

anardil commented Dec 23, 2024

Hello,

Can you provide an example to use a webhook, please?

Thank you.

@fmotalleb
Copy link
Author

Hi!, @anardil
In our company, we use a service called n8n as the integration point for managing workflows. For example, to configure a webhook with Semaphore, you can set the following environment variables:

SEMAPHORE_ALERT_WEBHOOK_ADDRESS="https://<your-n8n-instance>/webhook/semaphore-alerts"
SEMAPHORE_ALERT_WEBHOOK_HEADERS='{"Authorization": "Basic <your-base64-encoded-credentials>"}'

In this setup:

  • SEMAPHORE_ALERT_WEBHOOK_ADDRESS specifies the endpoint where Semaphore sends alert payloads. (POST request)
  • SEMAPHORE_ALERT_WEBHOOK_HEADERS allows you to include custom headers, such as authentication tokens or API keys.

the body looks like this

{
  "task": {
    "id": 57,
    "template_id": 3,
    "project_id": 1,
    "status": "success",
    "debug": false,
    "dry_run": false,
    "diff": false,
    "playbook": "",
    "environment": "{}",
    "limit": "",
    "secret": "{}",
    "arguments": null,
    "git_branch": null,
    "user_id": 1,
    "integration_id": null,
    "schedule_id": null,
    "created": "2024-12-01T07:59:12.373491465Z",
    "start": "2024-12-01T07:59:12.942863215Z",
    "end": null,
    "message": "",
    "commit_hash": null,
    "commit_message": "",
    "build_task_id": null,
    "version": null,
    "inventory_id": null,
    "params": {}
  },
  "template": {
    "id": 3,
    "project_id": 1,
    "inventory_id": 3,
    "repository_id": 1,
    "environment_id": 1,
    "name": "Docker Cleanup",
    "playbook": "docker/prune.yaml",
    "arguments": "[]",
    "allow_override_args_in_task": false,
    "description": null,
    "vaults": [],
    "type": "",
    "start_version": null,
    "build_template_id": null,
    "view_id": null,
    "last_task": {
      "id": 57,
      "template_id": 3,
      "project_id": 1,
      "status": "waiting",
      "debug": false,
      "dry_run": false,
      "diff": false,
      "playbook": "",
      "environment": "{}",
      "limit": "",
      "secret": "",
      "arguments": null,
      "git_branch": null,
      "user_id": 1,
      "integration_id": null,
      "schedule_id": null,
      "created": "2024-12-01T07:59:12.373491Z",
      "start": null,
      "end": null,
      "message": "",
      "commit_hash": null,
      "commit_message": "",
      "build_task_id": null,
      "version": null,
      "inventory_id": null,
      "params": {},
      "tpl_playbook": "docker/prune.yaml",
      "tpl_alias": "Docker Cleanup",
      "tpl_type": "",
      "tpl_app": "ansible",
      "user_name": "Admin",
      "build_task": null
    },
    "autorun": false,
    "git_branch": null,
    "survey_vars": null,
    "suppress_success_alerts": false,
    "app": "ansible",
    "tasks": 20,
    "task_params": null
  },
  "inventory": {
    "id": 3,
    "name": "all-servers",
    "project_id": 1,
    "inventory": "inventory.yaml",
    "ssh_key_id": 2,
    "become_key_id": null,
    "type": "file",
    "holder_id": null,
    "repository_id": 1
  },
  "repository": {
    "id": 1,
    "name": "_",
    "project_id": 1,
    "git_url": "_",
    "git_branch": "main",
    "ssh_key_id": 2
  },
  "environments": {
    "id": 1,
    "name": "Empty",
    "project_id": 1,
    "password": null,
    "json": "{}",
    "env": null,
    "secrets": null
  }
}

@johnsturgeon
Copy link

Yes please! I was just scouring the discussions trying to figure out if there is a way for me to monitor job runs using 'pings' to Uptime Kuma or Healthchecks.io, and this would do the trick!

Is there any update on timing of this PR?

@fmotalleb
Copy link
Author

Hi @johnsturgeon, At the time this PR was created, it appeared they had no plans to update the notification system. The maintainer mentioned in the Telegram group that the current implementation is layered with patches and needs a complete refactor. They’d rather rebuild the whole system than introduce this feature.
I’ve migrated my Ansible tasks to a Jenkins workflow.

@fmotalleb
Copy link
Author

I’m closing this PR due to inactivity; there has been no participation since December 2024.

@fmotalleb fmotalleb closed this Jul 2, 2025
@johnsturgeon
Copy link

Thanks for the update, I'm going to start using rundeck instead since it seems to be a much more robust / mature solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants