capistrano-slackify 1.2.2 → 2.0.0
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/.travis.yml +1 -1
- data/README.md +8 -9
- data/capistrano-slackify.gemspec +1 -1
- data/lib/capistrano/tasks/slackify.cap +5 -5
- data/lib/slackify.rb +6 -40
- data/spec/lib/slackify_spec.rb +30 -12
- data/spec/spec_helper.rb +0 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe9d66451d1e3749363f4ee105e8e4d79bcddbda
|
4
|
+
data.tar.gz: 361a987c04fc365b388a5fb45d360adc6010b4ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98826d18cfe708a109498c45bf986938672c6d641255495d50af0458db3c7488022f272b5a7af27ddc330199b9ec227a51557667ab4475b38031430e1ecc95b7
|
7
|
+
data.tar.gz: f0dd5d1a4405a5890b566cf558c74a819258e43db365cc19e9cb7634c8743b2ed3500e5808b103c4eca69b0c3467c5978866ba0e5122b2a3c1d717138ae2d148
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Capistrano Slackify [](https://travis-ci.org/onthebeach/capistrano-slackify)
|
1
|
+
# Capistrano Slackify [](https://travis-ci.org/onthebeach/capistrano-slackify) [](https://codeclimate.com/github/onthebeach/capistrano-slackify)
|
2
2
|
|
3
3
|
Publish deploy notifications to [Slack](https://slack.com) - for [Capistrano v3](https://github.com/capistrano/capistrano).
|
4
4
|
|
@@ -24,19 +24,18 @@ Require the gem in your `Capfile`:
|
|
24
24
|
|
25
25
|
And then set the required variables in `config/deploy.rb`:
|
26
26
|
|
27
|
-
set :
|
28
|
-
set :slack_token, 'my_slack_token'
|
27
|
+
set :slack_url, 'https://hooks.slack.com/services/your/webhook/url'
|
29
28
|
|
30
|
-
Ensure that you have enabled the [incoming webhooks integration](https://api.slack.com/)
|
29
|
+
Ensure that you have enabled the [incoming webhooks integration](https://api.slack.com/) -
|
30
|
+
copy/paste the webhook url provided in the setup instructions.
|
31
31
|
|
32
32
|
The task will run automatically on deploy. Alternatively, you can notify of a deploy starting manually by using:
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
bundle exec cap production slack:notify_started
|
35
|
+
|
36
36
|
Or to notify of a finished deploy:
|
37
37
|
|
38
|
-
|
39
|
-
|
38
|
+
bundle exec cap production slack:notify_started
|
40
39
|
|
41
40
|
By default, this will publish something along the lines of:
|
42
41
|
|
@@ -56,7 +55,7 @@ Any of the defaults can be over-ridden in `config/deploy.rb`:
|
|
56
55
|
"#{fetch(:application)} deployed to #{fetch(:stage)} by #{fetch(:slack_user)} " \
|
57
56
|
"in #{elapsed} seconds."
|
58
57
|
}
|
59
|
-
set :slack_deploy_starting_text, -> {
|
58
|
+
set :slack_deploy_starting_text, -> {
|
60
59
|
"#{fetch(:stage)} deploy starting with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
|
61
60
|
}
|
62
61
|
|
data/capistrano-slackify.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = 'capistrano-slackify'
|
7
|
-
spec.version = '
|
7
|
+
spec.version = '2.0.0'
|
8
8
|
spec.authors = ['seenmyfate']
|
9
9
|
spec.email = ['seenmyfate@gmail.com']
|
10
10
|
spec.summary = %q{Publish deployment notifications to Slack via the incoming webhooks integration}
|
@@ -6,7 +6,7 @@ namespace :slack do
|
|
6
6
|
info 'Notifying Slack of deploy starting'
|
7
7
|
set :time_started, Time.now.to_i
|
8
8
|
execute :curl, '-X POST',
|
9
|
-
'--data-urlencode', Slackify::Payload.build(:start),
|
9
|
+
'--data-urlencode', Slackify::Payload.build(self, :start),
|
10
10
|
fetch(:slack_url)
|
11
11
|
end
|
12
12
|
end
|
@@ -19,7 +19,7 @@ namespace :slack do
|
|
19
19
|
info 'Notifying Slack of deploy finished'
|
20
20
|
set :time_finished, Time.now.to_i
|
21
21
|
execute :curl, '-X POST',
|
22
|
-
'--data-urlencode', Slackify::Payload.build(:finish),
|
22
|
+
'--data-urlencode', Slackify::Payload.build(self, :finish),
|
23
23
|
fetch(:slack_url)
|
24
24
|
end
|
25
25
|
end
|
@@ -33,14 +33,14 @@ namespace :load do
|
|
33
33
|
set :slack_emoji, ':ghost:'
|
34
34
|
set :slack_parse, 'default'
|
35
35
|
set :slack_user, -> { local_user.strip }
|
36
|
-
set :slack_url, -> {
|
36
|
+
set :slack_url, -> { fail ':slack_url is not set' }
|
37
37
|
set :slack_text, lambda {
|
38
38
|
time_elapsed = Integer(fetch(:time_finished) - fetch(:time_started))
|
39
39
|
"Revision #{fetch(:current_revision, fetch(:branch))} of " \
|
40
40
|
"#{fetch(:application)} deployed to #{fetch(:stage)} by #{fetch(:slack_user)} " \
|
41
|
-
"in #{time_elapsed} seconds."
|
41
|
+
"in #{time_elapsed} seconds."
|
42
42
|
}
|
43
|
-
set :slack_deploy_starting_text, -> {
|
43
|
+
set :slack_deploy_starting_text, -> {
|
44
44
|
"#{fetch(:stage)} deploy starting with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
|
45
45
|
}
|
46
46
|
end
|
data/lib/slackify.rb
CHANGED
@@ -1,37 +1,17 @@
|
|
1
|
-
require 'uri'
|
2
1
|
require 'yajl/json_gem'
|
3
|
-
require 'singleton'
|
4
2
|
|
5
3
|
module Slackify
|
6
|
-
class URL
|
7
|
-
def initialize(subdomain, token)
|
8
|
-
@subdomain, @token = subdomain, token
|
9
|
-
end
|
10
|
-
|
11
|
-
def to_s
|
12
|
-
uri.to_s
|
13
|
-
end
|
14
|
-
|
15
|
-
private
|
16
|
-
|
17
|
-
def uri
|
18
|
-
@uri ||= URI(
|
19
|
-
"https://#{@subdomain}.slack.com/services/hooks/incoming-webhook?token=#{@token}"
|
20
|
-
)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
4
|
class Payload
|
25
5
|
|
26
6
|
attr_reader :status
|
27
7
|
protected :status
|
28
8
|
|
29
|
-
def
|
30
|
-
|
9
|
+
def initialize(context, status)
|
10
|
+
@context, @status = context, status
|
31
11
|
end
|
32
12
|
|
33
|
-
def
|
34
|
-
|
13
|
+
def self.build(context, status)
|
14
|
+
new(context, status).build
|
35
15
|
end
|
36
16
|
|
37
17
|
def build
|
@@ -56,23 +36,9 @@ module Slackify
|
|
56
36
|
end
|
57
37
|
end
|
58
38
|
|
59
|
-
|
60
|
-
|
61
|
-
class Configuration
|
62
|
-
include Singleton
|
63
|
-
|
64
|
-
def url
|
65
|
-
URL.new(subdomain, token).to_s
|
39
|
+
def fetch(*args, &block)
|
40
|
+
@context.fetch(*args, &block)
|
66
41
|
end
|
67
42
|
|
68
|
-
private
|
69
|
-
|
70
|
-
def subdomain
|
71
|
-
fetch(:slack_subdomain) { fail ':slack_subdomain is not set' }
|
72
|
-
end
|
73
|
-
|
74
|
-
def token
|
75
|
-
fetch(:slack_token) { fail ':slack_token is not set' }
|
76
|
-
end
|
77
43
|
end
|
78
44
|
end
|
data/spec/lib/slackify_spec.rb
CHANGED
@@ -1,22 +1,40 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
module Slackify
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
describe Payload do
|
5
|
+
describe '.build' do
|
6
|
+
let(:context) {
|
7
|
+
{
|
8
|
+
slack_channel: '#general',
|
9
|
+
slack_username:'Capistrano',
|
10
|
+
slack_emoji: ':ghost:',
|
11
|
+
slack_parse: 'default',
|
12
|
+
slack_user: 'You',
|
13
|
+
slack_text: ':boom:',
|
14
|
+
slack_deploy_starting_text: 'duck!'
|
15
|
+
}
|
16
|
+
}
|
8
17
|
|
9
|
-
|
10
|
-
|
11
|
-
|
18
|
+
context 'when starting' do
|
19
|
+
let(:payload) {
|
20
|
+
%{'payload={"channel":"#general","username":"Capistrano","text":"duck!","icon_emoji":":ghost:","parse":"default"}'}
|
21
|
+
}
|
22
|
+
|
23
|
+
it 'returns the starting payload' do
|
24
|
+
expect(Payload.build(context, :start)).to eq payload
|
25
|
+
end
|
12
26
|
end
|
13
|
-
end
|
14
27
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
28
|
+
context 'when finishing' do
|
29
|
+
let(:payload) {
|
30
|
+
%{'payload={"channel":"#general","username":"Capistrano","text":":boom:","icon_emoji":":ghost:","parse":"default"}'}
|
31
|
+
}
|
32
|
+
|
33
|
+
it 'returns the finishing payload' do
|
34
|
+
expect(Payload.build(context, :finish)).to eq payload
|
35
|
+
end
|
19
36
|
end
|
37
|
+
|
20
38
|
end
|
21
39
|
end
|
22
40
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-slackify
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- seenmyfate
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.4.2
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Publish deployment notifications to Slack via the incoming webhooks integration
|