Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
4
Help us understand the problem. What is going on with this article?

More than 5 years have passed since last update.

@hiro_y

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

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が指定できるので、いろいろ工夫できそうです。しばらく試してみようと思います。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
4
Help us understand the problem. What is going on with this article?