capistrano-slackify 2.0.1 → 2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb7a88b489f738c1ba6819ba9f906818bad7c576
4
- data.tar.gz: 2bc0070ea65b7a95b9e1494aa8d5813ff977523d
3
+ metadata.gz: 9b5dafba0cc5d7f3d89a6962a72fc000006f1405
4
+ data.tar.gz: d7f9938e73652330237b3e8ad2176ff7ff9f0c67
5
5
  SHA512:
6
- metadata.gz: a6a1e2e739bf9091632ffbb43c521a6a9acc7fdd12f9834c0fb96b6916b36ab99f09ce53b62315cdbdafa03e0ce29980b851a35392237d8c54b2bc3951007763
7
- data.tar.gz: b575a0979c90d7f0a216de5584eeb85e0de0969058962de83e9344313f718d76cd90b9c0e75d4b54bee80005c928fc7d172706ab11247ac21ac9a65929595277
6
+ metadata.gz: e95d083bc7f952d2ff386512b00cfe7231d9906bd0d65701feedb852c79005a7e684cb9a3f615bddeb03106f460f97867453c876bc48ef17693eda02dd827f0d
7
+ data.tar.gz: cb202d398accaa1e998b329bdee9db9488294ea4707823b32ece765ac835b3cfcd1f9d7a48a26da0c63a842e459529c512167dd77ce6f802cb349ca0915df557
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Capistrano Slackify [![Build Status](https://travis-ci.org/onthebeach/capistrano-slackify.svg)](https://travis-ci.org/onthebeach/capistrano-slackify) [![Code Climate](https://codeclimate.com/github/onthebeach/capistrano-slackify/badges/gpa.svg)](https://codeclimate.com/github/onthebeach/capistrano-slackify)
1
+ # Capistrano Slackify [![Build Status](https://travis-ci.org/onthebeach/capistrano-slackify.svg)](https://travis-ci.org/onthebeach/capistrano-slackify) [![Code Climate](https://codeclimate.com/github/onthebeach/capistrano-slackify/badges/gpa.svg)](https://codeclimate.com/github/onthebeach/capistrano-slackify) [![Gem Version](https://badge.fury.io/rb/capistrano-slackify.svg)](http://badge.fury.io/rb/capistrano-slackify)
2
2
 
3
3
  Publish deploy notifications to [Slack](https://slack.com) - for [Capistrano v3](https://github.com/capistrano/capistrano).
4
4
 
@@ -41,6 +41,14 @@ By default, this will publish something along the lines of:
41
41
 
42
42
  Revision 64a3c1de of my_app deployed to production by seenmyfate in 333 seconds.
43
43
 
44
+ If a deploy has failed, the following message will be published by default:
45
+
46
+ production deploy of my_app with revision/branch 64a3c1de failed
47
+
48
+ As with the other tasks, it is also possible to notify failures manually:
49
+
50
+ bundle exec cap production slack:notify_failed
51
+
44
52
  ### Customisation
45
53
 
46
54
  Any of the defaults can be over-ridden in `config/deploy.rb`:
@@ -58,10 +66,13 @@ Any of the defaults can be over-ridden in `config/deploy.rb`:
58
66
  set :slack_deploy_starting_text, -> {
59
67
  "#{fetch(:stage)} deploy starting with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
60
68
  }
69
+ set :slack_deploy_failed_text, -> {
70
+ "#{fetch(:stage)} deploy of #{fetch(:application)} with revision/branch #{fetch(:current_revision, fetch(:branch))} failed"
71
+ }
61
72
 
62
73
  To configure the way slack parses your message (see 'Parsing Modes' at https://api.slack.com/docs/formatting) use the `:slack_parse` setting:
63
74
 
64
- set :slack_parse, 'none' # available options: 'default', 'none', 'full'
75
+ set :slack_parse, 'none' # available options: 'default', 'none', 'full'
65
76
 
66
77
  ### Copyright
67
78
 
@@ -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 = '2.0.1'
7
+ spec.version = '2.1.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}
@@ -5,8 +5,8 @@ namespace :slack do
5
5
  run_locally do
6
6
  info 'Notifying Slack of deploy starting'
7
7
  set :time_started, Time.now.to_i
8
- execute :curl, '-X POST',
9
- '--data-urlencode', Slackify::Payload.build(self, :start),
8
+ execute :curl, '-X POST', '--data-urlencode',
9
+ Slackify::Payload.build(self, fetch(:slack_deploy_starting_text)),
10
10
  fetch(:slack_url)
11
11
  end
12
12
  end
@@ -18,12 +18,25 @@ namespace :slack do
18
18
  run_locally do
19
19
  info 'Notifying Slack of deploy finished'
20
20
  set :time_finished, Time.now.to_i
21
- execute :curl, '-X POST',
22
- '--data-urlencode', Slackify::Payload.build(self, :finish),
21
+ execute :curl, '-X POST', '--data-urlencode',
22
+ Slackify::Payload.build(self, fetch(:slack_text)),
23
23
  fetch(:slack_url)
24
24
  end
25
25
  end
26
26
  after 'deploy:finished', 'slack:notify_finished'
27
+
28
+ desc 'Notify Slack of a deployment failure via the incoming webhooks ' \
29
+ 'integration - :slack_subdomain and :slack_token must be set'
30
+ task :notify_failed do
31
+ run_locally do
32
+ info 'Notifying Slack of deploy failed'
33
+ set :time_finished, Time.now.to_i
34
+ execute :curl, '-X POST', '--data-urlencode',
35
+ Slackify::Payload.build(self, fetch(:slack_deploy_failed_text)),
36
+ fetch(:slack_url)
37
+ end
38
+ end
39
+ after 'deploy:failed', 'slack:notify_failed'
27
40
  end
28
41
 
29
42
  namespace :load do
@@ -43,5 +56,8 @@ namespace :load do
43
56
  set :slack_deploy_starting_text, -> {
44
57
  "#{fetch(:stage)} deploy starting with revision/branch #{fetch(:current_revision, fetch(:branch))} for #{fetch(:application)}"
45
58
  }
59
+ set :slack_deploy_failed_text, -> {
60
+ "#{fetch(:stage)} deploy of #{fetch(:application)} with revision/branch #{fetch(:current_revision, fetch(:branch))} failed"
61
+ }
46
62
  end
47
63
  end
@@ -3,15 +3,15 @@ require 'yajl/json_gem'
3
3
  module Slackify
4
4
  class Payload
5
5
 
6
- attr_reader :status
7
- protected :status
6
+ attr_reader :text
7
+ protected :text
8
8
 
9
- def initialize(context, status)
10
- @context, @status = context, status
9
+ def initialize(context, text)
10
+ @context, @text = context, text
11
11
  end
12
12
 
13
- def self.build(context, status)
14
- new(context, status).build
13
+ def self.build(context, text)
14
+ new(context, text).build
15
15
  end
16
16
 
17
17
  def build
@@ -22,20 +22,12 @@ module Slackify
22
22
  {
23
23
  channel: fetch(:slack_channel),
24
24
  username: fetch(:slack_username),
25
- text: slack_text,
25
+ text: text,
26
26
  icon_emoji: fetch(:slack_emoji),
27
27
  parse: fetch(:slack_parse)
28
28
  }.to_json
29
29
  end
30
30
 
31
- def slack_text
32
- if @status == :start
33
- fetch(:slack_deploy_starting_text)
34
- else
35
- fetch(:slack_text)
36
- end
37
- end
38
-
39
31
  def fetch(*args, &block)
40
32
  @context.fetch(*args, &block)
41
33
  end
@@ -11,28 +11,17 @@ module Slackify
11
11
  slack_parse: 'default',
12
12
  slack_user: 'You',
13
13
  slack_text: ':boom:',
14
- slack_deploy_starting_text: 'duck!'
15
14
  }
16
15
  }
17
16
 
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
26
- end
17
+ let(:payload) {
18
+ %{'payload={"channel":"#general","username":"Capistrano","text":":boom:","icon_emoji":":ghost:","parse":"default"}'}
19
+ }
27
20
 
28
- context 'when finishing' do
29
- let(:payload) {
30
- %{'payload={"channel":"#general","username":"Capistrano","text":":boom:","icon_emoji":":ghost:","parse":"default"}'}
31
- }
21
+ let(:text) { context.fetch(:slack_text) }
32
22
 
33
- it 'returns the finishing payload' do
34
- expect(Payload.build(context, :finish)).to eq payload
35
- end
23
+ it 'returns the payload with the specified text' do
24
+ expect(Payload.build(context, text)).to eq payload
36
25
  end
37
26
 
38
27
  end
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: 2.0.1
4
+ version: 2.1.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-20 00:00:00.000000000 Z
11
+ date: 2014-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capistrano
@@ -128,4 +128,3 @@ summary: Publish deployment notifications to Slack via the incoming webhooks int
128
128
  test_files:
129
129
  - spec/lib/slackify_spec.rb
130
130
  - spec/spec_helper.rb
131
- has_rdoc: