LoginSignup
4
4

More than 5 years have passed since last update.

IdobataにCapistrano(2系)のdeploy通知を投げる

Last updated at Posted at 2013-11-28

Idobataというグループチャットサービスを試しています。GitHubやNew Relicとの連携機能が便利。

現在のプロジェクトではPHPを使っており、New Relicのdeploy通知を利用できないので自前で通知するようにしてみました。deployツールとしてはCapistrano 2系(with Multistage)を使っています。

Generic Hookを使って「Idobataにデプロイの通知をさせる」を参考にしつつ、config/deploy.rbに以下の内容を追記すればOKでした。

after "deploy", "deploy:notify_revision"
namespace :deploy do
  task :notify_revision do
    user_name = `git config --global user.name`.gsub("\n", '')
    github_path = "https://github.com/YOUR-NAME/YOUR-REPOSITORY-NAME/tree/#{current_revision}"
    source = "<p>YOUR-PROJECT was deployed by #{user_name} <span class=\"label label-success\">#{stage}</span></p><ul><li>deployed source tree: <a href=\"#{github_path}\" target=\"_blank\">#{current_revision[0, 7]}</a></li></ul>"
    idobata_hook_url = "https://idobata.io/hook/xxxxx-xxxxx-xxxxx"  # Room Settings > Manage hooks
    run "curl --data-urlencode 'source=#{source}' -d format=html #{idobata_hook_url}"
  end
end

sourceオプションには好きなHTMLが指定できるので、いろいろ工夫できそうです。しばらく試してみようと思います。

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