capistrano-hook 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -6
- data/capistrano-hook.gemspec +1 -2
- data/config/deploy/production.rb +6 -4
- data/config/deploy.rb +6 -0
- data/lib/capistrano/hook/version.rb +1 -1
- data/lib/capistrano/tasks/webhook.rake +39 -41
- metadata +3 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6734a63af83178f4c7b8199305e4a70aa5e4f31
|
4
|
+
data.tar.gz: c4b53ab0c45b1874b7b2a9d7283404626407f1a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4621f0f1b45015a06115978e31ce8333871db88fae44ad8f59ff40efce5adc516d5aa86c7357ad237abdf2d17e9c8d46a1a3c9fb3a60b59d1eeec8697217f378
|
7
|
+
data.tar.gz: 44be5d2351f624f3314638837899e3806bb66ee83a8c06ec5245ff3283332ff8bf9de264eec3cbcc3abb634087fca346efdd645d23f33ed0dd2b8ec8b90478ee
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/capistrano-hook.svg)](http://badge.fury.io/rb/capistrano-hook)
|
4
4
|
[![Build Status](https://travis-ci.org/yulii/capistrano-hook.svg)](https://travis-ci.org/yulii/capistrano-hook)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/yulii/capistrano-hook/badges/gpa.svg)](https://codeclimate.com/github/yulii/capistrano-hook)
|
5
6
|
[![Dependency Status](https://gemnasium.com/yulii/capistrano-hook.svg)](https://gemnasium.com/yulii/capistrano-hook)
|
6
7
|
|
7
8
|
Notification hooks include start, finish and fail of deployments.
|
@@ -25,18 +26,30 @@ require 'capistrano/hook'
|
|
25
26
|
Capistrano hook will not be run with no settings. You can setting the variables shown below.
|
26
27
|
|
27
28
|
```ruby
|
28
|
-
set :webhook_url, '
|
29
|
-
set :webhook_starting_payload,
|
30
|
-
set :webhook_finished_payload,
|
31
|
-
set :webhook_failed_payload,
|
29
|
+
set :webhook_url, 'https://yulii.github.io/services'
|
30
|
+
set :webhook_starting_payload, { text: 'Now, deploying...' }
|
31
|
+
set :webhook_finished_payload, { text: 'Deployment has been completed!' }
|
32
|
+
set :webhook_failed_payload, { text: 'Oops! something went wrong.' }
|
33
|
+
set :webhook_reverting_payload, { text: 'Reverting...' }
|
34
|
+
set :webhook_rollbacked_payload, { text: 'Rollback has been completed!' }
|
32
35
|
```
|
33
36
|
|
37
|
+
Test your setup by running:
|
38
|
+
```
|
39
|
+
cap production webhook:post:starting
|
40
|
+
cap production webhook:post:finished
|
41
|
+
cap production webhook:post:failed
|
42
|
+
cap production webhook:post:reverting
|
43
|
+
cap production webhook:post:rollbacked
|
44
|
+
```
|
45
|
+
|
46
|
+
|
34
47
|
### Slack
|
35
48
|
|
36
|
-
|
49
|
+
Send notifications to Slack via incoming webhooks.
|
37
50
|
|
38
51
|
```ruby
|
39
|
-
set :webhook_url, '
|
52
|
+
set :webhook_url, 'https://yulii.github.io/services'
|
40
53
|
set :webhook_starting_payload, {
|
41
54
|
username: 'Capistrano',
|
42
55
|
icon_emoji: ':monkey_face:',
|
data/capistrano-hook.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['yulii']
|
10
10
|
spec.email = ['yone.info@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = 'Simple
|
12
|
+
spec.summary = 'Simple webhooks for Capistrano deployments.'
|
13
13
|
spec.description = 'Notification hooks include start, finish and fail of deployments.'
|
14
14
|
spec.homepage = 'https://github.com/yulii/capistrano-hook'
|
15
15
|
spec.license = 'MIT'
|
@@ -25,6 +25,5 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
26
|
spec.add_development_dependency 'minitest'
|
27
27
|
spec.add_development_dependency 'minitest-reporters'
|
28
|
-
spec.add_development_dependency 'webmock'
|
29
28
|
spec.add_development_dependency 'rubocop'
|
30
29
|
end
|
data/config/deploy/production.rb
CHANGED
@@ -21,10 +21,12 @@
|
|
21
21
|
|
22
22
|
# Configuration
|
23
23
|
# =============
|
24
|
-
set :webhook_url, '
|
25
|
-
set :webhook_starting_payload,
|
26
|
-
set :webhook_finished_payload,
|
27
|
-
set :webhook_failed_payload,
|
24
|
+
set :webhook_url, MOCK_URL[(ENV['STATUS_CODE'] || '200')]
|
25
|
+
set :webhook_starting_payload, text: '[production] Now, deploying...'
|
26
|
+
set :webhook_finished_payload, text: '[production] Deployment has been completed!'
|
27
|
+
set :webhook_failed_payload, text: '[production] Oops! something went wrong.'
|
28
|
+
set :webhook_reverting_payload, text: '[production] Reverting...'
|
29
|
+
set :webhook_rollbacked_payload, text: '[production] Rollback has been completed!'
|
28
30
|
|
29
31
|
# The server-based syntax can be used to override options:
|
30
32
|
# ------------------------------------
|
data/config/deploy.rb
CHANGED
@@ -12,6 +12,12 @@ set :log_level, :debug
|
|
12
12
|
|
13
13
|
set :keep_releases, 5
|
14
14
|
|
15
|
+
# API Mock URL
|
16
|
+
MOCK_URL = {
|
17
|
+
'200' => 'http://www.mocky.io/v2/55d33a90ec91e92b0e5e8e18',
|
18
|
+
'406' => 'http://www.mocky.io/v2/55d6557a54774eed102a494c'
|
19
|
+
}
|
20
|
+
|
15
21
|
namespace :deploy do
|
16
22
|
after :restart, :clear_cache do
|
17
23
|
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
@@ -5,14 +5,24 @@ namespace :webhook do
|
|
5
5
|
You can setting the variables shown below.
|
6
6
|
|
7
7
|
set :webhook_url, 'https://yulii.github.io'
|
8
|
-
set :webhook_starting_payload,
|
9
|
-
set :webhook_finished_payload,
|
10
|
-
set :webhook_failed_payload,
|
8
|
+
set :webhook_starting_payload, { text: 'Now, deploying...' }
|
9
|
+
set :webhook_finished_payload, { text: 'Deployment has been completed!' }
|
10
|
+
set :webhook_failed_payload, { text: 'Oops! something went wrong.' }
|
11
|
+
set :webhook_reverting_payload, { text: 'Reverting...' }
|
12
|
+
set :webhook_rollbacked_payload, { text: 'Rollback has been completed!' }
|
11
13
|
|
12
14
|
DESC
|
13
15
|
|
14
|
-
def
|
15
|
-
|
16
|
+
def webhook(url, payload)
|
17
|
+
return if url.nil? || payload.nil? || payload.empty?
|
18
|
+
info "POST #{url} payload='#{payload}'"
|
19
|
+
result = Capistrano::Hook::Web.client(url).post(payload)
|
20
|
+
message = "HTTP #{result.code} #{result.message} body='#{result.body}'; "
|
21
|
+
if result.is_a?(Net::HTTPSuccess)
|
22
|
+
info message
|
23
|
+
else
|
24
|
+
error message
|
25
|
+
end
|
16
26
|
end
|
17
27
|
|
18
28
|
namespace :post do
|
@@ -20,17 +30,7 @@ namespace :webhook do
|
|
20
30
|
run_locally do
|
21
31
|
url = fetch(:webhook_url)
|
22
32
|
payload = fetch(:webhook_starting_payload)
|
23
|
-
|
24
|
-
begin
|
25
|
-
result = Capistrano::Hook::Web.client(url).post(payload)
|
26
|
-
if result.is_a?(Net::HTTPSuccess)
|
27
|
-
info response_message(result, payload)
|
28
|
-
else
|
29
|
-
error response_message(result, payload)
|
30
|
-
end
|
31
|
-
rescue StandardError => e
|
32
|
-
error "[webhook:post:starting] #{e.class} #{e.message}"
|
33
|
-
end
|
33
|
+
webhook(url, payload)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
@@ -38,17 +38,7 @@ namespace :webhook do
|
|
38
38
|
run_locally do
|
39
39
|
url = fetch(:webhook_url)
|
40
40
|
payload = fetch(:webhook_finished_payload)
|
41
|
-
|
42
|
-
begin
|
43
|
-
result = Capistrano::Hook::Web.client(url).post(payload)
|
44
|
-
if result.is_a?(Net::HTTPSuccess)
|
45
|
-
info response_message(result, payload)
|
46
|
-
else
|
47
|
-
error response_message(result, payload)
|
48
|
-
end
|
49
|
-
rescue StandardError => e
|
50
|
-
error "[webhook:post:finishing] #{e.class} #{e.message}"
|
51
|
-
end
|
41
|
+
webhook(url, payload)
|
52
42
|
end
|
53
43
|
end
|
54
44
|
|
@@ -56,22 +46,30 @@ namespace :webhook do
|
|
56
46
|
run_locally do
|
57
47
|
url = fetch(:webhook_url)
|
58
48
|
payload = fetch(:webhook_failed_payload)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
49
|
+
webhook(url, payload)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
task :reverting do
|
54
|
+
run_locally do
|
55
|
+
url = fetch(:webhook_url)
|
56
|
+
payload = fetch(:webhook_reverting_payload)
|
57
|
+
webhook(url, payload)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
task :rollbacked do
|
62
|
+
run_locally do
|
63
|
+
url = fetch(:webhook_url)
|
64
|
+
payload = fetch(:webhook_rollbacked_payload)
|
65
|
+
webhook(url, payload)
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
73
|
-
before 'deploy:starting',
|
74
|
-
after 'deploy:finishing',
|
75
|
-
after 'deploy:failed',
|
69
|
+
before 'deploy:starting', 'webhook:post:starting'
|
70
|
+
after 'deploy:finishing', 'webhook:post:finished'
|
71
|
+
after 'deploy:failed', 'webhook:post:failed'
|
72
|
+
before 'deploy:reverting', 'webhook:post:reverting'
|
73
|
+
after 'deploy:finishing_rollback', 'webhook:post:rollbacked'
|
76
74
|
end
|
77
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capistrano-hook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yulii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|
@@ -80,20 +80,6 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: webmock
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
83
|
- !ruby/object:Gem::Dependency
|
98
84
|
name: rubocop
|
99
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -160,5 +146,5 @@ rubyforge_project:
|
|
160
146
|
rubygems_version: 2.4.5
|
161
147
|
signing_key:
|
162
148
|
specification_version: 4
|
163
|
-
summary: Simple
|
149
|
+
summary: Simple webhooks for Capistrano deployments.
|
164
150
|
test_files: []
|