gbp-notifications
gbp-notifications is a plugin for Gentoo Build Publisher that can send notifications when various events occur in a GBP instance. This is to scratch my personal itch where i want to receive emails when certain machines have new builds pulled.
gbp-notifications supports the following built-in notification methods:
- webhook
- pushover
Other notification methods can be added via a plugin system.
Installation
This assumes you already have a working Gentoo Build Publisher installation. If not refer to the GBP Install Guide first.
Install the gbp-notifications package onto the GBP instance.
cd /home/gbp
sudo -u gbp -H ./bin/pip install gbp-notifications
Restart your web app.
systemctl restart gentoo-build-publisher-wsgi.service
Configuration
Environment variables
Like Gentoo Build Publisher itself, gbp-notifications relies on environment
variables for configuration. It looks at variables with a GBP_NOTIFICATIONS_
prefix. For example to set up a recipient to receive email notifications when
a build for the machine "babette" gets pulled:
# /etc/gentoo-build-publisher.conf
GBP_NOTIFICATIONS_RECIPIENTS="albert:email=marduk@host.invalid"
GBP_NOTIFICATIONS_SUBSCRIPTIONS="babette.postpull=albert"
GBP_NOTIFICATIONS_EMAIL_FROM="marduk@host.invalid"
GBP_NOTIFICATIONS_EMAIL_SMTP_HOST="smtp.email.invalid"
GBP_NOTIFICATIONS_EMAIL_SMTP_USERNAME="marduk@host.invalid"
GBP_NOTIFICATIONS_EMAIL_SMTP_PASSWORD="supersecret"
The first two lines are setting up recipients and subscriptions. There is a
single recipient named albert that has an email address. The second line
sets up subscriptions. There is one subscription: when the machine "babette"
receives a postpull event the the recipient with the name "albert" will be
notified. Since "albert" has one notification method defined (email) that
recipient will be notified via email.
The wildcard is supported for machines and events, on subscriptions. So
*.postpull=albert means "send a notification to albert when any machine
receives a postpull event" and babette.*=albert means "send a notification
to albert when any event is receive for the machine babette. The
double-wildcard, *.*=albert does what you'd think. Notifications are only
sent once per recipient (per notification method).
The last lines are settings for the email notification method. gbp-notifications has support for multiple notification methods but currently only email is implemented.
Config file for Recipients and Subscriptions
Alternatively you can use a toml-formatted config file for recipients and
subscriptions. For that instead define the GBP_NOTIFICATIONS_CONFIG_FILE
environment variable that points to the path of the config file, e.g.
GBP_NOTIFICATIONS_CONFIG_FILE="/etc/gbp-subscribers.toml"
Then in your config file, the above configuration would look like this:
[recipients]
albert = {email = "marduk@host.invalid"}
[subscriptions]
babette = {postpull = ["albert"]}
A more sophisticated example might be:
[recipients]
# Albert and Bob are recipients with email addresses.
albert = {email = "marduk@host.invalid"}
bob = {email = "bob@host.invalid"}
[subscriptions]
# Both Albert and Bob want to be notified when builds for babette are pulled
babette = {postpull = ["albert", "bob"]}
# For lighthouse Albert only wants to be notified when builds are pulled. Bob
# only wants to be notified when builds are published.
lighthouse = {postpull = ["albert"], published = ["bob"]}
Webhook method
In addition to email, gbp-notifications supports web hooks. For example, consider the environment variables:
GBP_NOTIFICATIONS_RECIPIENTS="marduk:webhook=http://host.invalid/webhook|X-Pre-Shared-Key=1234",
GBP_NOTIFICATIONS_SUBSCRIPTIONS="*.postpull=marduk"
The subscriber "marduk" is subscribed the postpull event for all machines.
The recipient for marduk has a "webhook". The configuration for the web hook
has values that are delimited with "|". The first item will be the URL of
the webhook and any remainint items will be HTTP headers used when requesting
the URL. Note that header definitions are to be given in form name=value and
not name: value.
Webhooks might be used, for example, to automatically update machines whenever a new build is published. Or perhaps a desktop notification:
Pushover method
Pushover is a service that allows apps to send push notifications to mobile and other devices. gbp-notifications supports the Pushover service. To enable gbp-notifications to sent Pushover notifications you'll need to create a user account as well as app key for your GBP instance. Then define the following denvironment variables:
# /etc/gentoo-build-publisher.conf
GBP_NOTIFICATIONS_PUSHOVER_USER_KEY="[Pushover user key]",
GBP_NOTIFICATIONS_PUSHOVER_APP_TOKEN"="[Pushover app token]",
Pushover subscriptions will look like this:
GBP_NOTIFICATIONS_RECIPIENTS="marduk:pushover=iphone16pro",
GBP_NOTIFICATIONS_SUBSCRIPTIONS="*.postpull=marduk"
Replacing "iphone16pro" with the device name you've registered with Pushover.
Metadata
Release files for gbp-notifications 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gbp_notifications-2.1.0.tar.gz | 32.2 kB | Without provenance | Details for gbp_notifications-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gbp_notifications-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for gbp_notifications-2.1.0-py3-none-any.whl |
Total release size: 61.0 kB
Release files / gbp_notifications-2.1.0.tar.gz
| Download URL | gbp_notifications-2.1.0.tar.gz |
|---|---|
| Size | 32.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
75687529d75040b25e319c653a16dd166f97849c4d142e157108e74cfb204338
|
|
BLAKE2b-256 checksum How to use checksums |
ef34e74a5c339edd669499b0558e6463a6e7cf772ca6b7a3630072db84302cd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / gbp_notifications-2.1.0-py3-none-any.whl
| Download URL | gbp_notifications-2.1.0-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d5c9d43a26fcb63a8d1487c640f1508315d50d60d7978e23f43e9fb7eb0a3a6
|
|
BLAKE2b-256 checksum How to use checksums |
af3110f9c94c34eac22be3420c7d760ca8cbd78f59e4300d8af398ac8a2bfc58
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for gbp-notifications 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.