Python script to send notifications to a matrix room.
- Python 94%
- Dockerfile 6%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
All checks were successful
ci/woodpecker/push/lint_docker Pipeline was successful
ci/woodpecker/push/lint_python Pipeline was successful
ci/woodpecker/push/build_docker Pipeline was successful
ci/woodpecker/push/build_docker_plugin Pipeline was successful
ci/woodpecker/tag/lint_docker Pipeline was successful
ci/woodpecker/tag/lint_python Pipeline was successful
ci/woodpecker/tag/build_docker Pipeline was successful
ci/woodpecker/tag/build_docker_plugin Pipeline was successful
|
||
| .meta | ||
| media | ||
| .gitignore | ||
| Containerfile | ||
| docs.md | ||
| LICENSE | ||
| matrix_notifier.py | ||
| README.md | ||
| requirements.txt | ||
| woodpecker_plugin_Containerfile | ||
matrix-notifier
Python script to send notifications to a matrix room.
Testing
To test this project you will need:
- The id of a user on a matrix server (referred hereafter as
<user_id>) - A token corresponding to that user (referred hereafter as
<matrix_token>) - The url of the matrix server (referred hereafter as
<server_url>) - The id of the room on which to send the message (referred hereafter as
<room_id>)
All commands are expected to be ran from the root directory of this project.
First build the Docker image with
docker build -t matrix-notifier:latest -f ./Containerfile .
Then send a test message with:
docker run --rm -e MATRIX_TOKEN="<matrix_token>"" matrix-notifier:latest send <server_url> <user_id> <room_id> "This is a test" "<h1>This is a test</h1>"
For example with bogus values:
docker run --rm -e MATRIX_TOKEN="syt_oyEt6NzA2Waer3EF8s5vWbrRBEt88JMS_icF5ZU" matrix-notifier:latest send https://mydomain.tld botuser !tfdBxJRkuvdqD3K7Ma:mydomain.tld "This is a test" "<h1>This is a test</h1>"
Woodpecker plugin
This code can be built to work as a woodpecker plugin.
docker build -t matrix-notifier-plugin:latest -f ./woodpecker_plugin_Containerfile .
In your Woodpecker pipeline, you can integrate the following step:
- name: Notification
image: registry.bobbyblues.com/matrix-notifier-plugin:1.0.0
settings:
homeserver: https://domain.tld
user_id: botuser
room_id: !tfdBxJRkuvdqD3K7Ma:mydomain.tld
message: "[CI] ⚠️ Step failed for your project."
message_html: "[CI] ⚠️ Step failed for <a href='$CI_PIPELINE_URL'>your</a> project."
matrix_token:
from_secret: matrix_token
And define the matrix_token secret, containing a valid matrix token for botuser, and limiting its access to the plugin.
Plugin documentation can be found in the docs.md file.