php-censor/docs/en/plugins/slack_notify.md

71 lines
2.2 KiB
Markdown
Raw Permalink Normal View History

Plugin SlackNotify
2017-01-04 13:22:20 +01:00
===================
2016-07-19 11:12:28 +02:00
2017-07-18 15:54:24 +02:00
This plugin joins a [Slack](https://www.slack.com/) room and sends a user-defined message, for example a "Build
Succeeded" message.
2016-07-17 16:20:35 +02:00
Installation
------------
The plugin depends on `maknz/slack` library. To use SlackNotify plugin you should install dependency:
```
composer require "maknz/slack"
```
2016-07-19 11:12:28 +02:00
Configuration
2017-01-04 13:22:20 +01:00
-------------
2016-07-19 11:12:28 +02:00
### Options
2016-07-17 16:20:35 +02:00
| Field | Required? | Description |
|-------|-----------|-------------|
| `webhook_url` | Yes | The URL to your Slack WebHook |
2016-07-21 19:02:11 +02:00
| `room` | No | Your Slack room name. Default - #php-censor |
2016-07-19 13:05:02 +02:00
| `username` | No | The name to send the message as. Default - PHP Censor |
2017-07-18 15:54:24 +02:00
| `icon` | No | The URL to the user icon or an emoji such as :ghost:. Default - The value configured on Slack's
WebHook setup |
| `message` | No | The message to send to the room. Default - `<%PROJECT_URI%|%PROJECT_TITLE%> - <%BUILD_URI%|Build
#%BUILD%> has finished for commit <%COMMIT_URI%|%SHORT_COMMIT% (%COMMIT_EMAIL%)> on branch <%BRANCH_URI%|%BRANCH%>` |
2016-07-17 16:20:35 +02:00
| `show_status` | No | Whether or not to append the build status as an attachment in slack. Default - true
2016-07-19 11:12:28 +02:00
### Examples
2016-07-17 16:20:35 +02:00
Send a message if the build fails:
```yaml
failure:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
2016-07-19 13:05:02 +02:00
room: "#php-censor"
username: "PHP Censor"
2016-07-17 16:20:35 +02:00
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% failed! :angry:"
show_status: false
```
Send a message if the build is successful:
```yaml
success:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
2016-07-19 13:05:02 +02:00
room: "#php-censor"
username: "PHP Censor"
2016-07-17 16:20:35 +02:00
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% succeeded! :smiley:"
show_status: false
```
Send a message every time the build runs:
```yaml
complete:
slack_notify:
webhook_url: "https://hooks.slack.com/services/R212T827A/G983UY31U/aIp0yuW9u0iTqwAMOEwTg"
2016-07-19 13:05:02 +02:00
room: "#php-censor"
username: "PHP Censor"
2016-07-17 16:20:35 +02:00
icon: ":ghost:"
message: "%PROJECT_TITLE% - build %BUILD% completed"
show_status: true
2016-07-19 11:12:28 +02:00
```