Notifier¶
通知設定の定義です。
Notifierはtypeとversionの値をもちます。
| Key | Type | Description | Example | Default |
|---|---|---|---|---|
| type | NotifierType | 通知のタイプ | slack | |
| version | (string) | Notifierのバージョン | 1 | 1 |
これらの値によって以下の仕様が変わります。
Notifierのプロパティ- 環境変数
以降のセクションでは${type}@v${version}という表記で紹介します。
たとえば、type=hoge, version=3の場合はhoge@v3となります。
slack@v2¶
Environmental variables¶
| Name | Required | Description | Example |
|---|---|---|---|
| SLACK_INCOMING_WEBHOOKS_URL | yes | Incoming WebhookのURL | https://hooks.slack.com/services/xx.. |
| SLACK_THREAD_TS | no | レスするスレッドのthread_ts |
1605793970.186200 |
古いWebhook URLはサポートしていません
json payloadでchannelなど上書き可能だった古いIncoming Webhook URLはサポートしていません。
新しいIncoming Webhook URLを使用してください。
※ 動作確認していないだけで動く可能性はありますが保証しません
Definitions¶
| Key | Type | Description | Example | Default |
|---|---|---|---|---|
| use_blocks | (bool) | Block Kitを使うかどうか | true | false |
use_blocks: trueのとき、通知メッセージにBlock Kitのblocks[]をjson文字列として指定するとBlock KitのUI表現を使って通知できます。
Examples¶
SlackのBlodk Kit方式で通知するNotifier¶
type: slack
version: 2
use_blocks: true
Block Kitを使ったメッセージの構築について¶
Block Kitの構築にはBlock Kit Builderが便利です。

Block Kit Builderで作成したJSONのblocks[]を切り出し、notifierを使うアドオンのメッセージに指定しましょう。
final/notifyの場合は以下のように指定します。
YAMLのヒアドキュメント>-を使うことでjsonをそのまま挿入できるのがポイントですね。
// 中略
notifiers:
jumeaux:
type: slack
version: 2
use_blocks: true
addons:
final:
- name: notify
config:
notifies:
- notifier: jumeaux
message: >-
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "{{ title }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": " 🟢 *Same: {{ summary.status.same }}*\n* 🟣 Diff: {{ summary.status.different }}*\n* 🟠 Fail: {{ summary.status.failure }}*"
},
"accessory": {
"type": "image",
"image_url": "https://avatars1.githubusercontent.com/u/9500018?s=160&v=4",
"alt_text": "alt text for image"
}
}
]
通知は以下のようになります。

もう少し情報を充実させた例も紹介します。
// 中略
notifiers:
jumeaux:
type: slack
version: 2
use_blocks: true
addons:
final:
- name: notify
config:
notifies:
- notifier: jumeaux2
message: >-
[
{
"type": "header",
"text": {
"type": "plain_text",
"text": "{{ title }}"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": " 🟢 *Same: {{ summary.status.same }}*\n* 🟣 Diff: {{ summary.status.different }}*\n* 🟠 Fail: {{ summary.status.failure }}*"
},
"accessory": {
"type": "image",
"image_url": "https://avatars1.githubusercontent.com/u/9500018?s=160&v=4",
"alt_text": "alt text for image"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "image",
"image_url": "https://tadashi-aikawa.github.io/jumeaux/img/logo-large.png",
"alt_text": "jumeaux"
},
{
"type": "mrkdwn",
"text": "v{{ version }}"
},
{
"type": "mrkdwn",
"text": "#️⃣ {{ key[:7] }}"
},
{% if summary.tags %}
{
"type": "mrkdwn",
"text": "🏷️️{% for x in summary.tags %} `{{ x }}`{% endfor %}"
},
{% endif %}
{
"type": "mrkdwn",
"text": "⏰ {{ summary.time.start[:19] | replace('T', ' ') }} ~ {{ summary.time.end[:19] | replace('T', ' ') }} ({{ summary.time.elapsed_sec }}秒)"
},
{
"type": "mrkdwn",
"text": "<{{ summary.one.host }}|{{ summary.one.name }}> 👈 🤖 👉 <{{ summary.other.host }}|{{ summary.other.name }}>"
}
]
}
]
このようになります。

slack@v1¶
Deprecated
version=1は非推奨であり、v3.0のリリースで廃止予定です。
version=2を使ってください。
Environmental variables¶
| Name | Required | Description | Example |
|---|---|---|---|
| SLACK_INCOMING_WEBHOOKS_URL | yes | Incoming WebhookのURL | https://hooks.slack.com/services/xx.. |
Definitions¶
| Key | Type | Description | Example | Default |
|---|---|---|---|---|
| channel | string | 通知先 | #times_test |
|
| username | (string) | 通知ユーザ名 | jenkins | jumeaux |
| icon_emoji | (string) | アイコンの絵文字 | smile | |
| icon_url | (string) | アイコンのURL | http://jumeaux/images.img |
Examples¶
Slackの#times_testチャンネルに通知するNotifier¶
type: slack
channel: "#times_test"
icon_emoji: "innocent"