LoginSignup
2
1

More than 5 years have passed since last update.

CircleCI2 でSlackに通知する

Last updated at Posted at 2017-12-25

はじめに

CircieCI 2 便利なんだけど、標準のチャット通知がわりとシンプルすぎて目が滑るため困る。

Slack_-_ROLLCAKE_Inc_.png

ワークフローを使っていると同じような通知が飛んできて、どのステップの通知なのかよくわからないし、自分でメッセージを作りつつ通知したい気持ちになった。

- run:
    name: Slack
    command: |
      GIT_REVISION=`git show -s --format=%H`
      PAYLOAD=`cat << EOS
      {
        "channel": "#test",
        "username": "CI",
        "icon_emoji": ":octocat:",
        "text": "<!here|here> デプロイしたよ :docker:",
        "attachments": [
          {
            "title": "Revision",
            "color": "good",
            "text": "<https://github.com/xxxxxx/xxxxxx/commit/$GIT_REVISION>"
          }
        ]
      }
      EOS
      `
      curl -X POST --data-urlencode "payload=$PAYLOAD" $SLACK_WEBHOOK_URL

Slack_-_ROLLCAKE_Inc_.png

いいですね

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1