capistrano-slack 1.1.7 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/capistrano-slack.gemspec +1 -1
- data/lib/capistrano/slack.rb +30 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26a6130cf204867a9f2dde0ff9e2d8997d0f4b38
|
4
|
+
data.tar.gz: 23b447fe47a9ac65e6584021456ee74b2e9afcb6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a0f967286203627f05be9b1656a7db4ce0fee69bbfa0db6f33b9bab7f97c0638dc2782328d597aea3f5964e7329fc19365b8751c0c740075be9efe1da6822d4
|
7
|
+
data.tar.gz: b1153cc552f22d36a1eba9fb3a578489aad4a1ee2aa417c228f2ea98c221dde395791fcad3d14b583101f35cc6a09d926c3ef7281a886d2084c69521783ba76c
|
data/capistrano-slack.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "capistrano-slack"
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Joshua Nichols", "Justin McNally"]
|
data/lib/capistrano/slack.rb
CHANGED
@@ -31,8 +31,21 @@ module Capistrano
|
|
31
31
|
else
|
32
32
|
"#{announced_deployer} is deploying #{application} to #{announced_stage}"
|
33
33
|
end
|
34
|
-
|
35
|
-
|
34
|
+
|
35
|
+
|
36
|
+
# Parse the API url and create an SSL connection
|
37
|
+
uri = URI.parse("https://#{slack_subdomain}.slack.com/services/hooks/incoming-webhook?token=#{slack_token}")
|
38
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
39
|
+
http.use_ssl = true
|
40
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
41
|
+
|
42
|
+
# Create the post request and setup the form data
|
43
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
44
|
+
request.set_form_data(:payload => {'channel' => slack_room, 'username' => 'deploybot', 'text' => announcement, "icon_emoji" => ":ghost:"}.to_json)
|
45
|
+
|
46
|
+
# Make the actual request to the API
|
47
|
+
response = http.request(request)
|
48
|
+
|
36
49
|
set(:start_time, Time.now)
|
37
50
|
end
|
38
51
|
|
@@ -47,9 +60,22 @@ module Capistrano
|
|
47
60
|
end_time = Time.now
|
48
61
|
start_time = fetch(:start_time)
|
49
62
|
elapsed = end_time.to_i - start_time.to_i
|
63
|
+
|
50
64
|
msg = "#{announced_deployer} deployed #{application} successfully in #{elapsed} seconds."
|
51
|
-
|
52
|
-
|
65
|
+
|
66
|
+
# Parse the URI and handle the https connection
|
67
|
+
uri = URI.parse("https://#{slack_subdomain}.slack.com/services/hooks/incoming-webhook?token=#{slack_token}")
|
68
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
69
|
+
http.use_ssl = true
|
70
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
71
|
+
|
72
|
+
# Create the post request and setup the form data
|
73
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
74
|
+
request.set_form_data(:payload => {'channel' => slack_room, 'username' => 'deploybot', 'text' => msg, "icon_emoji" => ":ghost:"}.to_json)
|
75
|
+
|
76
|
+
# Make the actual request to the API
|
77
|
+
response = http.request(request)
|
78
|
+
|
53
79
|
rescue Faraday::Error::ParsingError
|
54
80
|
# FIXME deal with crazy color output instead of rescuing
|
55
81
|
# it's stuff like: ^[[0;33m and ^[[0m
|