Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

HipChat HTTP API Wrapper in Ruby with Capistrano hooks

branch: master

This branch is 0 commits ahead and 0 commits behind master

Merge pull request #23 from ismaelga/master

Just a little formatting fix on Readme file
latest commit 4456ac04e8
Craig P Jolicoeur cpjolicoeur authored
Octocat-spinner-32 lib cancelled message color June 12, 2012
Octocat-spinner-32 spec Adjusted test suite for notify depreciations November 28, 2011
Octocat-spinner-32 .document Initial commit to hipchat. October 25, 2010
Octocat-spinner-32 .gitignore Initial commit to hipchat. October 25, 2010
Octocat-spinner-32 LICENSE Change copyright. October 26, 2010
Octocat-spinner-32 README.textile Little formatting fix in Readme August 23, 2012
Octocat-spinner-32 Rakefile Cleaning up ownership info for gemspec October 07, 2011
Octocat-spinner-32 VERSION Version bump to 0.4.1 October 19, 2011
Octocat-spinner-32 hipchat.gemspec Regenerate gemspec for version 0.4.1 October 19, 2011
README.textile

HipChat Wrapper

A very basic wrapper for the HipChat HTTP API.

Usage

client = HipChat::Client.new(api_token)
client['my room'].send('username', 'I talk')

# Send notifications to users (default false)
client['my room'].send('username', 'I quit!', :notify => true)

# Color it red. or "yellow", "green", "purple", "random" (default "yellow")
client['my room'].send('username', 'Build failed!', :color => 'red')

Capistrano

require 'hipchat/capistrano'

set :hipchat_token, "<your token>"
set :hipchat_room_name, "Your room"
set :hipchat_announce, false # notify users
set :hipchat_color, 'green' #finished deployment message color
set :hipchat_failed_color, 'red' #cancelled deployment message color

Who did it?

To determine the user that is currently running the deploy, the capistrano tasks will look for the following:

  1. The $HIPCHAT_USER environment variable
  2. The hipchat_human capistrano var.
  3. The git user.name var.
  4. The $USER environment variable.

Rails 3 Rake Task

Send a message using a rake task:

rake hipchat:send["hello world"]

Options like the room, API token, user name and notification flag can be set in YAML.

RAILS_ROOT/config/hipchat.yml:

token: "<your token>"
room: "Your room"
user: "Your name" # Default to `whoami`
notify: true # Defaults to false

Engine Yard

Use a deploy hook to send messages from Engine Yard’s Cloud platform.

RAILS_ROOT/deploy/after_restart.rb:

on_app_master do
  message  = "Deploying revision #{revision[0...6]} to #{node[:environment][:name]}"
  message += " (with migrations)" if migrate?
  message += "."

  # Send a message via rake task assuming a hipchat.yml in your config like above
  run "cd #{release_path} && bundle exec rake hipchat:send MESSAGE='#{message}'"
end

Copyright

Copyright © 2010 Mojo Tech. See LICENSE for details.

Something went wrong with that request. Please try again.