Skip to main content

gbp-notifications webhook server

Project description

gbp-webhook

gbp-webhook is a web service that responds to webhook notifications given from the gbp-notifications plugin. It shows a nice desktop notification whenever the machines of your choice pull a build. That's what it does by default, however plugins can be written to respond to any event that gbp-notifications responds to.

screenshot

Features

  • Command-line interface integrates with gbpcli
  • Does not require root access to run
  • Security
    • IP whitelisting
    • Pre-shared key
    • Optional SSL (TLS) support
  • Plugin support to handle gbp-notifications however you like

Installation

These instructions assume you already have gbpcli, the command-line interface for Gentoo Build Publisher, installed on your desktop.

If you've installed gbpcli via pip install --user:

pip install --user gbp-webhook

If you've installed gbpcli via pipx:

pipx inject gbpcli gbp-webhook

Usage

Set the pre-shared key with an environment variable

GBP_WEBHOOK_PRE_SHARED_KEY=our_little_secret
export GBP_WEBHOOK_PRE_SHARED_KEY

Run the server

gbp webhook serve --port 5000 --allow 10.10.10.23

The --port argument is the port you wish the webhook to listen on. It is optional and defaults to 5000.

The --allow argument is an IP or IP/mask that is allowed to send requests to the webhook server. Multiple IPs can be passed. All other IPs are forbidden so if no --allow flags are passed then the server will refuse all requests.

gbp-webhook uses nginx as a front-end. You do not need to be root to start nginx or run nginx as a system service, however you do need to tell gbp-webhook where the nginx executable resides if it is anywhere other than /usr/sbin/nginx. This is done with the --nginx argument. For example:

gbp webhook serve --port 5000 --nginx ~/.local/bin/nginx

Ok so now the service is running on your desktop system, but you need to configure the server. This is where gbp-notifications comes in. Refer to the gbp-notifications installation instructions, then configure it to talk to your gbp-webhook server. Here's an exampl TOML config:

[recipients]
laptop = { webhook = "http://10.10.10.100:5000/webhook|X-Pre-Shared-Key=our_little_secret" }

[subscriptions]
"*" = {build_pulled = ["laptop"]}

If you use the TOML config you won't need to restart the GBP service to read the config. However if you are using environment variables configuration you will.

Now when a build is pulled, gbp-notifications will send an HTTP request to the webhook service on your laptop, which will in turn display a desktop notification.

Systemd Integration

gbp-webhook can be run manually from the command line as outlined above. However it's nicer if it is able to automatically start in the background when you log into your desktop environment. For this gbp-webhook is able to install a systemd unit file for you:

gbp webhook install --port 5000 --nginx ~/.local/bin/nginx

This installs a gbp-webhook.service unit in ~/.local/share/systemd/user. It also installs a config file in ~/.config/gbp-webhook.conf. You can then enable and start the service with:

systemctl enable --user --now gbp-webhook

Now it will start automatically when you log in. To uninstall the service:

gbp webhook uninstall

Environment Variables

The following variables are read from ~/.config/gbp-webhook.conf:

  • GBP_WEBHOOK_PRE_SHARED_KEY: as explained above, the pre-shared key exchanged between Gentoo Build Publisher and gbp-webhook.
  • GBP_WEBHOOK_NGINX: If defined, this is the full path to the nginx executable. The default is /usr/sbin/nginx.
  • GBP_WEBHOOK_ARGS: additional arguments to pass to gbp-webhook. Run gbp webhook --help to see the available arguments.

Plugins

gbp-webhook has a plugin mechanism were the webhook can call arbitrary handlers. The following additional plugins are known to exist:

Plugin Description
playsound A plugin that plays a sound on build pulled events
tts A text-to-speech plugin to speak the name of a machine or machines when a build is pulled for that machine

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gbp_webhook-1.0.0.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gbp_webhook-1.0.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file gbp_webhook-1.0.0.tar.gz.

File metadata

  • Download URL: gbp_webhook-1.0.0.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gbp_webhook-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f33ca92d1aed0b6bf78fb15d861cce0d4da869bbcb4f60b676b17ac00fa70014
MD5 2c85e5a5d86554dabac159109a8e57dc
BLAKE2b-256 6cf255b1bb34ff84b17e5fde6015077773b974c8491a6f5372f989e303772335

See more details on using hashes here.

File details

Details for the file gbp_webhook-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gbp_webhook-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for gbp_webhook-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eb8b0a6b3cb537bfcd778872b2a37973defa4d483282b5318d282b956f12cee5
MD5 f7d1b85056223f826781a08a73e61b1c
BLAKE2b-256 a43baa10a98389f07dbf13ccea19a757c00d2862a14fdabe81955ddfec84b16d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page