Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(alerts): webhook alert + messenger proxy support #2603

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from

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
  }
}

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.

3 participants