2023-07-22 16:22:35 +02:00
# drone-matrixchat-notify
2023-07-24 14:17:04 +02:00
[![MIT License ](https://img.shields.io/github/license/SpotlightKid/drone-matrixchat-notify?label=License )](https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/LICENSE)
[![GitHub tag (with filter) ](https://img.shields.io/github/v/tag/SpotlightKid/drone-matrixchat-notify?filter=v*.*.*&logo=github&label=Latest%20version )](https://github.com/SpotlightKid/drone-matrixchat-notify/tags)
[![Docker image version ](https://img.shields.io/docker/v/spotlightkid/drone-matrixchat-notify?logo=docker&label=Docker+image )](https://hub.docker.com/r/spotlightkid/drone-matrixchat-notify)
[![GitHub stars ](https://img.shields.io/github/stars/SpotlightKid/drone-matrixchat-notify?logo=github&label=GitHub )](https://github.com/SpotlightKid/drone-matrixchat-notify)
[![GitLab stars ](https://img.shields.io/gitlab/stars/SpotlightKid%2Fdrone-matrixchat-notify?logo=gitlab&label=GitLab )](https://gitlab.com/SpotlightKid/drone-matrixchat-notify)
[![GitHub issues ](https://img.shields.io/github/issues/SpotlightKid/drone-matrixchat-notify?logo=github&label=Issues )](https://github.com/SpotlightKid/drone-matrixchat-notify/issues)
A [drone.io] [plugin] to send notifications to Matrix chat rooms from CIs
pipeline steps. Supports *Jinja* message templates and *Markdown* rendering.
2023-07-22 16:22:35 +02:00
Example pipeline configuration:
```yaml
kind: pipeline
type: docker
name: default
steps:
- name: build
image: alpine
commands:
- ./build
- name: notify
image: spotlightkid/drone-matrixchat-notify
settings:
homeserver: 'https://matrix.org'
roomid: '!xxxxxx@matrix.org'
userid: '@drone-bot@matrix.org'
password:
from_secret: drone-bot-pw
template: '${DRONE_REPO} ${DRONE_COMMIT_SHA} ${DRONE_BUILD_STATUS}'
```
2023-07-22 16:44:50 +02:00
## Configuration settings
2023-07-22 16:22:35 +02:00
2023-07-23 23:15:08 +02:00
* `allowed_attrs` *(default:* [`DEFAULT_ALLOWED_ATTRS`]*)*
List or string with comma-separated list of HTML attribute names or
dict mapping tag names to lists of attributes names.
See the bleach documentation on [allowed attributes] for more information.
2023-07-23 23:09:55 +02:00
* `allowed_tags` *(default:* [`DEFAULT_ALLOWED_TAGS`]*)*
List or set or string with comma-separated list of HTML tag names. HTML
2023-07-24 01:07:32 +02:00
tags not included will be stripped from the HTML output generated by
2023-07-23 23:09:55 +02:00
rendering a Markdown message template.
Note that the default list does not include any tags, which allow to load
external resources when the generated HTML is displayed, notably `img`
is not included.
2023-07-22 16:22:35 +02:00
* `accesstoken`
Access token to use for authentication instead of `password` . Either an
access token or a password is required.
* `deviceid`
Device ID to send with access token.
* `devicename`
Device name to send with access token.
* `homeserver` *(default:* `https://matrix.org` *)*
The Matrix homeserver URL.
2023-07-24 01:07:32 +02:00
* `jinja`
If set to `yes` , `y` , `true` , `t` , `on` or `1` , the message template is
rendered with the [Jinja] templating engine (instead of performing simple
placeholder substitution). The template context is controlled by the
`pass_environment` setting, same as with non-Jinja templates, but
placeholders use a different syntax (example: `{{DRONE_REPO}}` ), so the
2023-07-24 14:17:04 +02:00
`template` setting should be changed to be a valid Jinja template string
2023-07-24 01:07:32 +02:00
when this is enabled.
Using this feature requires the `jinja2` Python module to be available
(it is installed by default in the plugin's docker image).
2023-07-22 16:22:35 +02:00
* `markdown`
2023-07-24 01:07:32 +02:00
If set to `yes` , `y` , `true` , `t` , `on` or `1` , the message resulting from
template substtution is considered to be in Markdown format and will be
rendered to HTML and sent as a formatted message with the format set to
`org.matrix.custom.html` .
2023-07-22 16:22:35 +02:00
2023-07-23 23:54:03 +02:00
Using this feature requires the `markdown` and `bleach` Python modules to
2023-07-24 01:07:32 +02:00
be available (they are installed by default in the plugin's docker image).
2023-07-23 23:54:03 +02:00
2023-07-23 23:09:55 +02:00
* `markdown_extensions` *(default:* `admonition, extra, sane_lists, smarty` )
Comma-separated list of enabled Markdown extensions. See this
[list of extensions] for valid extension names. Including an invalid
extension name in this list will disable Markdown rendering.
2023-07-23 19:34:25 +02:00
* `pass_environment` *(default:* `DRONE_*` *)*
Comma-separated white-list of environment variable names or name patterns.
Patterns are shell-glob style patterns and case-sensitive.
Only environment variables matching any of the given names or patterns will
be available as valid placeholders in the message template.
2023-07-22 16:22:35 +02:00
* `password`
Password to use for authenticating the user set with `userid` . Either a
password or an access token is required.
* `roomid` *(required)*
ID of matrix chat room to send messages to (ID, not alias).
* `template` *(default:* `${DRONE_BUILD_STATUS}` *)*
2023-07-24 01:07:32 +02:00
The message template. Valid placeholders (example: `${DRONE_REPO}` ) will be
substituted with the values of the matching environment variables (subject
to filtering according to the `pass_environment` setting).
2023-07-22 16:22:35 +02:00
2023-07-22 22:13:59 +02:00
See this [reference] for environment variables available in drone.io CI
2023-07-22 16:22:35 +02:00
pipelines.
* `userid` *(required)*
ID of user on homeserver to send message as (ID, not username).
2023-07-24 14:17:04 +02:00
[`DEFAULT_ALLOWED_ATTRS`]: https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/matrixchat-notify.py#L28
[`DEFAULT_ALLOWED_TAGS`]: https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/matrixchat-notify.py#L35
2023-07-23 23:09:55 +02:00
[allowed attributes]: https://bleach.readthedocs.io/en/latest/clean.html#allowed-attributes-attributes
2023-07-22 16:22:35 +02:00
[drone.io]: https://drone.io/
2023-07-24 01:07:32 +02:00
[jinja]: https://jinja.palletsprojects.com/
2023-07-23 23:09:55 +02:00
[list of extensions]: https://python-markdown.github.io/extensions/
2023-07-22 16:22:35 +02:00
[plugin]: https://docs.drone.io/plugins/overview/
2023-07-24 01:07:32 +02:00
[reference]: https://docs.drone.io/pipeline/environment/reference/