capistrano-slack 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/capistrano-slack.gemspec +2 -1
- data/lib/capistrano/slack.rb +62 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dd98f5eae3700c11ee2badacbe40edf4605c840
|
4
|
+
data.tar.gz: 1460cf6d73c1c80d811898ea05fc9576c80898a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a0fe1bf927d7e4f294f589ad2c0f31d70d7e286f26d99f3f970112619e744737909c9c458dc161a8e5407925ca2ba899892663081ecaa9940ef6b53603f402d
|
7
|
+
data.tar.gz: ed862ba6cca5727f95f965e53b527e1680a7e97a868185bb85b1cb7a9a903149d84dc3ae6a071354107ed6a76757eaf2da8451ac217c4f3fc1277ed817d8cf1e
|
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.5"
|
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"]
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
"Rakefile",
|
26
26
|
"capistrano-slack.gemspec",
|
27
27
|
"lib/capistrano-slack.rb",
|
28
|
+
"lib/capistrano/slack.rb",
|
28
29
|
"spec/.rspec",
|
29
30
|
"spec/capistrano-slack_spec.rb",
|
30
31
|
"spec/spec_helper.rb",
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'capistrano/log_with_awesome'
|
3
|
+
require 'json'
|
4
|
+
# TODO need to handle loading a bit beter. these would load into the instance if it's defined
|
5
|
+
module Capistrano
|
6
|
+
module Slack
|
7
|
+
def self.extended(configuration)
|
8
|
+
configuration.load do
|
9
|
+
|
10
|
+
before 'deploy', 'slack:starting'
|
11
|
+
before 'deploy:migrations', 'slack:starting'
|
12
|
+
after 'deploy', 'slack:finished'
|
13
|
+
|
14
|
+
set :deployer do
|
15
|
+
ENV['GIT_AUTHOR_NAME'] || `git config user.name`.chomp
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
namespace :slack do
|
20
|
+
task :starting do
|
21
|
+
slack_token = fetch(:slack_token)
|
22
|
+
slack_room = fetch(:slack_room)
|
23
|
+
slack_subdomain = fetch(:slack_subdomain)
|
24
|
+
return if slack_token.nil?
|
25
|
+
announced_deployer = fetch(:deployer)
|
26
|
+
announced_stage = fetch(:stage, 'production')
|
27
|
+
|
28
|
+
announcement = if fetch(:branch, nil)
|
29
|
+
"#{announced_deployer} is deploying #{application}'s #{branch} to #{announced_stage}"
|
30
|
+
else
|
31
|
+
"#{announced_deployer} is deploying #{application} to #{announced_stage}"
|
32
|
+
end
|
33
|
+
uri = URI("https://#{slack_subdomain}.slack.com/services/hooks/incoming-webhook?token=#{slack_token}")
|
34
|
+
res = Net::HTTP.post_form(uri, :payload => {'channel' => slack_room, 'username' => 'deploybot', 'text' => announcement, "icon_emoji" => ":ghost:"}.to_json)
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
task :finished do
|
40
|
+
begin
|
41
|
+
slack_token = fetch(:slack_token)
|
42
|
+
slack_room = fetch(:slack_room)
|
43
|
+
slack_subdomain = fetch(:slack_subdomain)
|
44
|
+
log = fetch(:full_log)
|
45
|
+
return if slack_token.nil?
|
46
|
+
uri = URI("https://#{slack_subdomain}.slack.com/services/hooks/incoming-webhook?token=#{slack_token}")
|
47
|
+
res = Net::HTTP.post_form(uri, :payload => {'channel' => slack_room, 'username' => 'deploybot', 'text' => log, "icon_emoji" => ":ghost:"}.to_json)
|
48
|
+
rescue Faraday::Error::ParsingError
|
49
|
+
# FIXME deal with crazy color output instead of rescuing
|
50
|
+
# it's stuff like: ^[[0;33m and ^[[0m
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if Capistrano::Configuration.instance
|
60
|
+
Capistrano::Configuration.instance.extend(Capistrano::Slack)
|
61
|
+
end
|
62
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-slack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Nichols
|
@@ -139,6 +139,7 @@ files:
|
|
139
139
|
- Rakefile
|
140
140
|
- capistrano-slack.gemspec
|
141
141
|
- lib/capistrano-slack.rb
|
142
|
+
- lib/capistrano/slack.rb
|
142
143
|
- spec/.rspec
|
143
144
|
- spec/capistrano-slack_spec.rb
|
144
145
|
- spec/spec_helper.rb
|