capistrano-slack-notify 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/capistrano-slack-notify.rb +1 -0
- data/lib/capistrano/slack_notify.rb +79 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 433098b8888f2bf24b9b31062062a0bd2e883f83
|
4
|
+
data.tar.gz: 6301e42d877a905da38a72cd9fa887d4315d9ac3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a349ecaa60fa8f1b2b1881f27414a3d956cbf765e34282b878f45b8e54379fa0c45fe3b3fcfce5f3ea72591f9a3b4b01aa102a7391fd4e184706f18391f46351
|
7
|
+
data.tar.gz: 76a77934629fcf2f2fd8a6c7558b90c41a6bbe89ff26a3b6240b391529c5796b2db77442fc29881bfaa9183c5d3d19879dfebc4b9f9f5f25bb927a740c1c2c18
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'capistrano/slack_notify'
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'json'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module Capistrano
|
6
|
+
module SlackNotify
|
7
|
+
def call_slack_api(message)
|
8
|
+
uri = URI.parse(slack_webhook_url)
|
9
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
10
|
+
http.use_ssl = true
|
11
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
12
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
13
|
+
request.set_form_data(:payload => payload(message))
|
14
|
+
http.request(request)
|
15
|
+
rescue SocketError => e
|
16
|
+
puts "#{e.message} or slack may be down"
|
17
|
+
end
|
18
|
+
|
19
|
+
def slack_defaults
|
20
|
+
if fetch(:slack_deploy_defaults, true)
|
21
|
+
before 'deploy', 'slack:starting'
|
22
|
+
after 'deploy', 'slack:finished'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def payload(announcement)
|
27
|
+
{
|
28
|
+
'channel' => fetch(:slack_room, '#platform'),
|
29
|
+
'username' => fetch(:slack_username, 'capistrano'),
|
30
|
+
'text' => announcement,
|
31
|
+
'icon_emoji' => fetch(:slack_emoji, ':rocket:')
|
32
|
+
}.to_json
|
33
|
+
end
|
34
|
+
|
35
|
+
def slack_webhook_url
|
36
|
+
fetch(:slack_webhook_url)
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.extended(configuration)
|
40
|
+
configuration.load do
|
41
|
+
slack_defaults
|
42
|
+
|
43
|
+
set :deployer do
|
44
|
+
ENV['USER'] || ENV['GIT_AUTHOR_NAME'] || `git config user.name`.chomp
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :slack do
|
48
|
+
desc "Notify Slack that the deploy has started."
|
49
|
+
task :starting do
|
50
|
+
msg = if branch = fetch(:branch, nil)
|
51
|
+
"#{fetch(:deployer)} is deploying #{fetch(:application)}/#{branch} to #{fetch(:stage, 'production')}"
|
52
|
+
else
|
53
|
+
"#{fetch(:deployer)} is deploying #{fetch(:application)} to #{fetch(:stage, 'production')}"
|
54
|
+
end
|
55
|
+
call_slack_api(msg)
|
56
|
+
set(:start_time, Time.now)
|
57
|
+
end
|
58
|
+
|
59
|
+
desc "Notify Slack that the deploy has completed successfully."
|
60
|
+
task :finished do
|
61
|
+
msg = "#{fetch(:deployer)} deployed to #{fetch(:application)} successfully"
|
62
|
+
if start_time = fetch(:start_time, nil)
|
63
|
+
elapsed = Time.now.to_i - start_time.to_i
|
64
|
+
msg << " in #{elapsed} seconds."
|
65
|
+
else
|
66
|
+
msg << "."
|
67
|
+
end
|
68
|
+
call_slack_api(msg)
|
69
|
+
end
|
70
|
+
end # end namespace :slack
|
71
|
+
end
|
72
|
+
end # end self.extended
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
if Capistrano::Configuration.instance
|
78
|
+
Capistrano::Configuration.instance.extend(Capistrano::SlackNotify)
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-slack-notify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Parker Moore
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.10'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- parkrmoore@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/capistrano-slack-notify.rb
|
63
|
+
- lib/capistrano/slack_notify.rb
|
64
|
+
homepage: https://github.com/parkr/capistrano-slack-notify
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 2.2.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Minimalist Capistrano 2 notifier for Slack.
|
88
|
+
test_files: []
|