0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CircleCIのジョブ結果をSlackに通知する

Posted at

背景

CircleCIのジョブ結果をSlackに通知する方法が変更になったので、その方法を記載する。

本題

旧バージョンでは、コンソール画面からWebhookURLに値を設定するのみだったが、現在は Orbs を利用するようになった。必要最低限の結果を受け取るための設定を以下に記述する。少々手間だが、 post-steps を利用して、ジョブ実行後のステップに差し込む。

./circleci/config.yml
version: 2.1 # post-stepsの利用のため2.1が必須

orbs:
  slack: circleci/slack@3.4.2

commands:
  notify_status:
    steps:
      - slack/status
      # カスタマイズ箇所は https://circleci.com/developer/orbs/orb/circleci/slack?version=3.4.2#commands-status から参照できる。

jobs:
 <job_name>:

workflows:
  version: 2
  workflow_name:
    jobs:
      - <job_name>:
          post-steps:
            - notify_status

バージョン

2020/11/20現在では circleci/slack@4.1.1 が最新。3.4.2との差分の注目点はテンプレートのカスタマイズ性だと思われる。custom-message-templateより、 Slackのビルダーキットで作ることができる。(調査背景・用途としては、ジョブの結果とコンソールへのURLさえ分かれば良かったので、実際には使っていない。)

課題

旧方法で通知設定しているプロジェクトを編集する方法について見つけられなかった。

参考

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?