Python script to send notifications to a matrix room.
Find a file
bobbyblues e4279d9aa9
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
feat: update documentation
fix: type
2025-06-23 14:29:23 +02:00
.meta feat: update documentation 2025-06-23 14:29:23 +02:00
.gitignore Initial commit 2025-05-23 22:18:02 +02:00
Containerfile feat(ci): add notification when pipeline fails. 2025-06-23 14:20:00 +02:00
LICENSE Initial commit 2025-05-23 22:18:02 +02:00
matrix_notifier.py fix: Python linting 2025-05-24 10:59:51 +02:00
README.md feat: update documentation 2025-06-23 14:29:23 +02:00
requirements.txt first version 2025-05-23 23:13:11 +02:00

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 integration

In your Woodpecker pipeline, you can integrate the following step:

  - name: Notification
    image: registry.bobbyblues.com/matrix-notifier:1.0.0
    environment:
      MATRIX_TOKEN:
        from_secret: matrix_token
    commands:
      - python /app/matrix_notifier.py
        send
        https://domain.tld
        botuser
        !tfdBxJRkuvdqD3K7Ma:mydomain.tld
        "[CI] ⚠️ Step failed for your project."
        "[CI] ⚠️ Step failed for <a href='$CI_PIPELINE_URL'>your</a> project."
    when: 
      - status: [failure]

And define the matrix_token secret, containing a valid matrix token for botuser.