3
2

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.

[備忘録]DroneをGitHubと連携してSlackに結果を通知する

Last updated at Posted at 2019-04-10

githubにpushしたらCIを動かして結果をSlackで受け取りたい

Droneを使ってやってみるよ

前提

  • Dockerインストール
  • GitHubにリポジトリある
  • Slackにincoming-webhookを追加

流れ

  1. GitHubにpush
  2. GitHubがWebHookでDroneマネージャーにhttpPOST通知
  3. DroneマネージャーがDroneエージェントに通知
  4. DroneエージェントがDockerに起動通知
  5. Dockerがjob実行用コンテナを起動する
  6. 終わったら結果をSlackで通知

まずプロジェクトにDrone設定を追加

プロジェクトルートに .drone.yml を追加
notifyでGitHub連携設定する
こんなかんじ?

pipeline:
  build-frontend:
    image: makimatsun/node:8-chrome
    commands:
      - npm install
      - npm run build --prod
      - rm -rf /deploy/frontend
      - mv dist/* /deploy/
    volumes:
      - /tmp/makimatsun-drone:/deploy

  build-docker-frontend:
  (略)

  ansible:
  (略)

  code-analysis:
  (略)

  cleanup:
  (略)

  notify:
    image: plugins/slack
    webhook: https://hooks.slack.com/services/~~~~
    channel: dev-makimatsun
    icon_emoji: ':drone:'
    username: drone
    when:
      status: [success]

  notify-failure:
    image: plugins/slack
    webhook: https://hooks.slack.com/services/~~~~
    channel: dev-makimatsun
    icon_emoji: ':drone_failure:'
    username: drone
    when:
      status: [failure]

Drone側の設定

https://ci.xxxxxxx/account/reposで対象のリポジトリをONにする
image.png

対象リポジトリのSettingでProject SettingsTrustedにチェックする
スクリーンショット 2019-04-10 17.27.11.png

3
2
1

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
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?