https://github.com/wlatanowicz/simple-slack-send
Easily send slack messages in your CI pipelines
https://github.com/wlatanowicz/simple-slack-send
ci slack
Last synced: about 1 month ago
JSON representation
Easily send slack messages in your CI pipelines
- Host: GitHub
- URL: https://github.com/wlatanowicz/simple-slack-send
- Owner: wlatanowicz
- Created: 2022-06-04T10:43:23.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T12:28:36.000Z (almost 4 years ago)
- Last Synced: 2025-09-25T11:59:27.439Z (9 months ago)
- Topics: ci, slack
- Language: Python
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple Slack Send - easily send slack messages in your CI pipelines
===
Simple Slack Send is designed to push templated slack notifications from you CI pipelines using Slack's incoming webhooks.
Template engine
---
Simple Slack Send uses [Jinja2](https://palletsprojects.com/p/jinja/) under the hood to produce Slack messages in JSON format. You can use any expression (values, includes, conditions, loops etc.) that is allowed by Jinja.
If the rendering engine's output is empty, no message is sent.
Parameter sources
---
Jinja templates are fed with values from multiple sources given as command arguments:
1. env files with key-value pairs ie. `-e production.env` or `--env-file=staging.env`
2. json files ie. `-j terraform-output.json` or `--env-file=infrastructure.json`
3. key-value pairs provided as command arguments ie. `-v env_name=jupiter` or `--var instance_type=small`
4. system environment - turned on/off with `--sys-env`/`--no-sys-env` option; on by default
Configuration
---
You can pass Slack's webhook url by settings `SLACK_WEBHOOK_URL` env variable or using `--webhook-url` argument.
Example usage
===
message.json.tpl:
```
{% if BITBUCKET_EXIT_CODE == "0" %}
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":large_green_circle: Commit {{ BITBUCKET_COMMIT }} built successfully."
}
}
]
}
{% else %}
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":red_circle: Commit {{ BITBUCKET_COMMIT }} failed to build. Visit for details."
}
}
]
}
{% endif %}
```
```
simple-slack-send message.json.tpl
```