Compare commits

..

No commits in common. "master" and "v0.2.0" have entirely different histories.

1 changed files with 23 additions and 38 deletions

View File

@ -1,14 +1,7 @@
# drone-matrixchat-notify # drone-matrixchat-notify
[![MIT License](https://img.shields.io/github/license/SpotlightKid/drone-matrixchat-notify?label=License)](https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/LICENSE) A [drone.io] [plugin] to send notifications to Matrix chat rooms from
[![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) CI pipeline steps.
[![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 CI
pipeline steps. Supports *Jinja* message templates and *Markdown* rendering.
Example pipeline configuration: Example pipeline configuration:
@ -31,36 +24,11 @@ steps:
userid: '@drone-bot@matrix.org' userid: '@drone-bot@matrix.org'
password: password:
from_secret: drone-bot-pw from_secret: drone-bot-pw
markdown: 'yes' template: '${DRONE_REPO} ${DRONE_COMMIT_SHA} ${DRONE_BUILD_STATUS}'
template: |
`${DRONE_REPO}` build #${DRONE_BUILD_NUMBER} status: **${DRONE_BUILD_STATUS}**
${DRONE_PULL_REQUEST_TITLE}](${DRONE_COMMIT_LINK})
``` ```
## Configuration settings ## Configuration settings
### Required
* `roomid` *(required)*
ID of matrix chat room to send messages to (ID, not alias).
* `userid` *(required)*
Matrix user ID on homeserver to send message as (ID, not username).
* `password` *(required)*
Password to use for authenticating the user set with `userid`. Either a
password or an access token is required.
* `accesstoken` *(required)*
Access token to use for authentication instead of `password`. Either an
access token or a password is required.
### Optional
* `allowed_attrs` *(default:* [`DEFAULT_ALLOWED_ATTRS`]*)* * `allowed_attrs` *(default:* [`DEFAULT_ALLOWED_ATTRS`]*)*
@ -79,6 +47,11 @@ steps:
external resources when the generated HTML is displayed, notably `img` external resources when the generated HTML is displayed, notably `img`
is not included. is not included.
* `accesstoken`
Access token to use for authentication instead of `password`. Either an
access token or a password is required.
* `deviceid` * `deviceid`
Device ID to send with access token. Device ID to send with access token.
@ -98,7 +71,7 @@ steps:
placeholder substitution). The template context is controlled by the placeholder substitution). The template context is controlled by the
`pass_environment` setting, same as with non-Jinja templates, but `pass_environment` setting, same as with non-Jinja templates, but
placeholders use a different syntax (example: `{{DRONE_REPO}}`), so the placeholders use a different syntax (example: `{{DRONE_REPO}}`), so the
`template` setting should be changed to be a valid Jinja template string `template` setting should be changed to be a valid Jinja2 template string
when this is enabled. when this is enabled.
Using this feature requires the `jinja2` Python module to be available Using this feature requires the `jinja2` Python module to be available
@ -128,6 +101,15 @@ steps:
Only environment variables matching any of the given names or patterns will Only environment variables matching any of the given names or patterns will
be available as valid placeholders in the message template. be available as valid placeholders in the message template.
* `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}`*)* * `template` *(default:* `${DRONE_BUILD_STATUS}`*)*
The message template. Valid placeholders (example: `${DRONE_REPO}`) will be The message template. Valid placeholders (example: `${DRONE_REPO}`) will be
@ -137,10 +119,13 @@ steps:
See this [reference] for environment variables available in drone.io CI See this [reference] for environment variables available in drone.io CI
pipelines. pipelines.
* `userid` *(required)*
ID of user on homeserver to send message as (ID, not username).
[`DEFAULT_ALLOWED_ATTRS`]: https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/matrixchat-notify.py#L28 [`DEFAULT_ALLOWED_ATTRS`]: ./matrixchat-notify.py#L27
[`DEFAULT_ALLOWED_TAGS`]: https://github.com/SpotlightKid/drone-matrixchat-notify/blob/master/matrixchat-notify.py#L35 [`DEFAULT_ALLOWED_TAGS`]: ./matrixchat-notify.py#L34
[allowed attributes]: https://bleach.readthedocs.io/en/latest/clean.html#allowed-attributes-attributes [allowed attributes]: https://bleach.readthedocs.io/en/latest/clean.html#allowed-attributes-attributes
[drone.io]: https://drone.io/ [drone.io]: https://drone.io/
[jinja]: https://jinja.palletsprojects.com/ [jinja]: https://jinja.palletsprojects.com/