7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/chinook/capistrano/hipchat.rb', line 7
def self.load_into(configuration)
configuration.load do
namespace :chinook do
desc 'Lets a HipChat room know about a deploy that has begun.'
task :hipchat_start, except: { no_release: true } do
unless exists?(:hipchat_room) && exists?(:hipchat_token)
logger.info 'Cannot notify HipChat without :hipchat_room and :hipchat_token. Skipping task.'
next
end
project_name = fetch(:project_name, application)
git_username = `git config user.name`.chomp
message = "#{git_username} started a deploy of #{project_name} to #{stage} at #{Time.now.strftime('%r %Z')}."
hipchat = ::HipChat::Client.new(fetch(:hipchat_token))
room = fetch(:hipchat_room)
username = fetch(:hipchat_username, 'Deployment')
hipchat[room].send(username, message, color: 'yellow')
end
desc 'Lets a HipChat channel know about a deploy that is rolling back.'
task :hipchat_rollback, except: { no_release: true } do
unless exists?(:hipchat_room) && exists?(:hipchat_token)
logger.info 'Cannot notify HipChat without :hipchat_room and :hipchat_token. Skipping task.'
next
end
project_name = fetch(:project_name, application)
git_username = `git config user.name`.chomp
message = "#{git_username}'s deploy of #{project_name} to #{stage} has been rolled back at #{Time.now.strftime('%r %Z')}."
hipchat = ::HipChat::Client.new(fetch(:hipchat_token))
room = fetch(:hipchat_room)
username = fetch(:hipchat_username, 'Deployment')
hipchat[room].send(username, message, color: 'red')
end
desc 'Lets a HipChat channel know about a deploy that has finished.'
task :hipchat_end, except: { no_release: true } do
unless exists?(:hipchat_room) && exists?(:hipchat_token)
logger.info 'Cannot notify HipChat without :hipchat_room and :hipchat_token. Skipping task.'
next
end
project_name = fetch(:project_name, application)
git_username = `git config user.name`.chomp
message = "#{git_username}'s deploy of #{project_name} to #{stage} finished at #{Time.now.strftime('%r %Z')}."
hipchat = ::HipChat::Client.new(fetch(:hipchat_token))
room = fetch(:hipchat_room)
username = fetch(:hipchat_username, 'Deployment')
hipchat[room].send(username, message, color: 'green')
end
end
end
end
|