slackistrano 0.1.11 → 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +90 -28
- data/examples/fomatting_with_fields.png +0 -0
- data/lib/slackistrano/tasks/slack.rake +28 -20
- data/lib/slackistrano/version.rb +1 -1
- data/spec/tasks_spec.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c083ad8d812b118fb281c5a0854423b18fbfe68
|
4
|
+
data.tar.gz: 3c1734032ce8f8ebd498f5d23dd32e6b6516592b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7731d4c976a9b5883c04ed483b13c94f8cb0785f479c3d01a753183d0863f163d0326b0d197fefa4573c3adf14f97176ed359bf09ee972f9d02c3471051d37b
|
7
|
+
data.tar.gz: 91793a4d0a8eaabfd79f33655269d5419134a6056449723e5f68ea355bed101ccefbfea4419b890fd2a5c97f03d48b273481d6d8d34e97c0a0b10d15ff8a7e39
|
data/README.md
CHANGED
@@ -18,11 +18,15 @@ If you need Capistrano v2 support, check out [capistrano-slack](https://github.c
|
|
18
18
|
|
19
19
|
Add this line to your application's Gemfile:
|
20
20
|
|
21
|
-
|
21
|
+
```ruby
|
22
|
+
gem 'slackistrano', require: false
|
23
|
+
```
|
22
24
|
|
23
25
|
And then execute:
|
24
26
|
|
25
|
-
|
27
|
+
```bash
|
28
|
+
$ bundle
|
29
|
+
```
|
26
30
|
|
27
31
|
## Configuration
|
28
32
|
|
@@ -35,47 +39,105 @@ In both case, you need to enable the integration inside Slack and get the token
|
|
35
39
|
|
36
40
|
Require the library in your application's Capfile:
|
37
41
|
|
38
|
-
|
42
|
+
```ruby
|
43
|
+
require 'slackistrano'
|
44
|
+
```
|
39
45
|
|
40
46
|
If you post using *Incoming Webhooks* you need to set your webhook url in your application's config/deploy.rb:
|
41
47
|
|
42
|
-
|
48
|
+
```ruby
|
49
|
+
set :slack_webhook, "https://hooks.slack.com/services/XXX/XXX/XXX"
|
50
|
+
```
|
43
51
|
|
44
52
|
If you choose to post using *Slackbot* you **must** set your team, token, and channel in your application's config/deploy.rb:
|
45
53
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
54
|
+
```ruby
|
55
|
+
set :slack_via_slackbot, true
|
56
|
+
set :slack_team, "teamname"
|
57
|
+
set :slack_token, "xxxxxxxxxxxxxxxxxxxxxxxx"
|
58
|
+
set :slack_channel, '#general'
|
59
|
+
```
|
50
60
|
|
51
61
|
Optionally, override the other slack settings:
|
52
62
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
63
|
+
```ruby
|
64
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
65
|
+
set :slack_icon_emoji, -> { nil } # will override icon_url, Must be a string (ex: ':shipit:')
|
66
|
+
set :slack_channel, -> { nil } # Channel to post to. Optional. Defaults to WebHook setting. Required if using Slackbot.
|
67
|
+
set :slack_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
68
|
+
set :slack_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
69
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
70
|
+
set :slack_username, -> { 'Slackistrano' }
|
71
|
+
set :slack_run_starting, -> { true }
|
72
|
+
set :slack_run_finished, -> { true }
|
73
|
+
set :slack_run_failed, -> { true }
|
74
|
+
set :slack_deploy_user, -> { ENV['USER'] || ENV['USERNAME'] }
|
75
|
+
set :slack_msg_starting, -> { "#{fetch :slack_deploy_user} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
76
|
+
set :slack_msg_finished, -> { "#{fetch :slack_deploy_user} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
77
|
+
set :slack_msg_failed, -> { "#{fetch :slack_deploy_user} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :rails_env, 'production'}" }
|
78
|
+
set :slack_fields_starting, -> { [] }
|
79
|
+
set :slack_fields_finished, -> { [] }
|
80
|
+
set :slack_fields_failed, -> { [] }
|
81
|
+
set :slack_fallback_starting, -> { nil }
|
82
|
+
set :slack_fallback_finished, -> { nil }
|
83
|
+
set :slack_fallback_failed, -> { nil }
|
84
|
+
set :slack_title_starting, -> { nil }
|
85
|
+
set :slack_title_finished, -> { nil }
|
86
|
+
set :slack_title_failed, -> { nil }
|
87
|
+
```
|
70
88
|
|
71
89
|
**Note**: You may wish to disable one of the notifications if another service (ex:
|
72
90
|
Honeybadger) also displays a deploy notification.
|
73
91
|
|
74
92
|
Test your setup by running:
|
75
93
|
|
76
|
-
|
77
|
-
|
78
|
-
|
94
|
+
```bash
|
95
|
+
$ cap production slack:deploy:starting
|
96
|
+
$ cap production slack:deploy:finished
|
97
|
+
$ cap production slack:deploy:failed
|
98
|
+
```
|
99
|
+
|
100
|
+
## Formatted messages
|
101
|
+
|
102
|
+
Slack allows you to send complex content, composed by fields. You can use the `fields` and `fallback` variables in order to have a well formatted message as follows:
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
set :slack_revision, `git rev-parse origin/master`.strip!
|
106
|
+
set :slack_title_finished, nil
|
107
|
+
set :slack_msg_finished, nil
|
108
|
+
set :slack_fallback_finished, "#{fetch(:slack_deploy_user)} deployed #{fetch(:application)} on #{fetch(:stage)}"
|
109
|
+
set :slack_fields_finished, [
|
110
|
+
{
|
111
|
+
"title": "Project",
|
112
|
+
"value": "<https://github.com/XXXXX/#{fetch(:application)}|#{fetch(:application)}>",
|
113
|
+
"short": true
|
114
|
+
},
|
115
|
+
{
|
116
|
+
"title": "Environment",
|
117
|
+
"value": fetch(:stage),
|
118
|
+
"short": true
|
119
|
+
},
|
120
|
+
{
|
121
|
+
"title": "Deployer",
|
122
|
+
"value": fetch(:slack_deploy_user),
|
123
|
+
"short": true
|
124
|
+
},
|
125
|
+
{
|
126
|
+
"title": "Revision",
|
127
|
+
"value": "<https://github.com/XXXXX/#{fetch(:application)}/commit/#{fetch(:slack_revision)}|#{fetch(:slack_revision)[0..6]}>",
|
128
|
+
"short": true
|
129
|
+
}
|
130
|
+
]
|
131
|
+
```
|
132
|
+
|
133
|
+
It will produce the following format:
|
134
|
+
![Formatted message](https://raw.githubusercontent.com/phallstrom/slackistrano/master/examples/fomatting_with_fields.png)
|
135
|
+
|
136
|
+
**Note 1:** *The `fallback` field is required in order to display notifications when using `fields`.*
|
137
|
+
|
138
|
+
**Note 2:** *The `fields` requires configuration requires you to use webhooks.*
|
139
|
+
|
140
|
+
More information: [https://api.slack.com/docs/attachments](https://api.slack.com/docs/attachments)
|
79
141
|
|
80
142
|
## Usage
|
81
143
|
|
Binary file
|
@@ -5,6 +5,8 @@ namespace :slack do
|
|
5
5
|
title: fetch(:"slack_title_#{stage}"),
|
6
6
|
pretext: fetch(:"slack_pretext_#{stage}"),
|
7
7
|
text: fetch(:"slack_msg_#{stage}"),
|
8
|
+
fields: fetch(:"slack_fields_#{stage}"),
|
9
|
+
fallback: fetch(:"slack_fallback_#{stage}"),
|
8
10
|
mrkdwn_in: [:text, :pretext]
|
9
11
|
}).reject{|k, v| v.nil? }
|
10
12
|
[attachments]
|
@@ -85,25 +87,31 @@ namespace :load do
|
|
85
87
|
set :slack_webhook, ->{ nil } # Incoming WebHook URL.
|
86
88
|
set :slack_via_slackbot, ->{ false } # Set to true to send the message via slackbot instead of webhook
|
87
89
|
|
88
|
-
set :slack_channel,
|
89
|
-
set :slack_channel_starting,
|
90
|
-
set :slack_channel_finished,
|
91
|
-
set :slack_channel_failed,
|
92
|
-
set :slack_icon_url,
|
93
|
-
set :slack_icon_emoji,
|
94
|
-
set :slack_username,
|
95
|
-
set :slack_run_starting,
|
96
|
-
set :slack_run_finished,
|
97
|
-
set :slack_run_failed,
|
98
|
-
set :slack_deploy_user,
|
99
|
-
set :slack_msg_starting,
|
100
|
-
set :slack_msg_finished,
|
101
|
-
set :slack_msg_failed,
|
102
|
-
set :
|
103
|
-
set :
|
104
|
-
set :
|
105
|
-
set :
|
106
|
-
set :
|
107
|
-
set :
|
90
|
+
set :slack_channel, -> { nil } # Channel to post to. Optional. Defaults to WebHook setting.
|
91
|
+
set :slack_channel_starting, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
92
|
+
set :slack_channel_finished, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
93
|
+
set :slack_channel_failed, -> { nil } # Channel to post to. Optional. Defaults to :slack_channel.
|
94
|
+
set :slack_icon_url, -> { 'http://gravatar.com/avatar/885e1c523b7975c4003de162d8ee8fee?r=g&s=40' }
|
95
|
+
set :slack_icon_emoji, -> { nil } # Emoji to use. Overrides icon_url. Must be a string (ex: ':shipit:')
|
96
|
+
set :slack_username, -> { 'Slackistrano' }
|
97
|
+
set :slack_run_starting, -> { true } # Set to false to disable starting message.
|
98
|
+
set :slack_run_finished, -> { true } # Set to false to disable finished message.
|
99
|
+
set :slack_run_failed, -> { true } # Set to false to disable failure message.
|
100
|
+
set :slack_deploy_user, -> { ENV['USER'] || ENV['USERNAME'] }
|
101
|
+
set :slack_msg_starting, -> { "#{fetch :slack_deploy_user} has started deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
102
|
+
set :slack_msg_finished, -> { "#{fetch :slack_deploy_user} has finished deploying branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
103
|
+
set :slack_msg_failed, -> { "#{fetch :slack_deploy_user} failed to deploy branch #{fetch :branch} of #{fetch :application} to #{fetch :stage, 'an unknown stage'}" }
|
104
|
+
set :slack_fields_starting, -> { [] }
|
105
|
+
set :slack_fields_finished, -> { [] }
|
106
|
+
set :slack_fields_failed, -> { [] }
|
107
|
+
set :slack_fallback_starting, -> { nil }
|
108
|
+
set :slack_fallback_finished, -> { nil }
|
109
|
+
set :slack_fallback_failed, -> { nil }
|
110
|
+
set :slack_title_starting, -> { nil }
|
111
|
+
set :slack_title_finished, -> { nil }
|
112
|
+
set :slack_title_failed, -> { nil }
|
113
|
+
set :slack_pretext_starting, -> { nil }
|
114
|
+
set :slack_pretext_finished, -> { nil }
|
115
|
+
set :slack_pretext_failed, -> { nil }
|
108
116
|
end
|
109
117
|
end
|
data/lib/slackistrano/version.rb
CHANGED
data/spec/tasks_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slackistrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philip Hallstrom
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-09-
|
11
|
+
date: 2015-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- LICENSE.txt
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
+
- examples/fomatting_with_fields.png
|
82
83
|
- lib/slackistrano.rb
|
83
84
|
- lib/slackistrano/tasks/slack.rake
|
84
85
|
- lib/slackistrano/version.rb
|