capistrano-hook 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/README.md +31 -8
- data/lib/capistrano/hook/version.rb +1 -1
- data/lib/capistrano/hook/web.rb +7 -3
- data/lib/capistrano/tasks/webhook.rake +36 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e5f778e0764d7fe69d8750bab671b06838bc931
|
4
|
+
data.tar.gz: b485c2534e1d2d94fc80a7f426c9fab725ccda42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2949d100809fa35d82bfb433558920b4673a20002bdb7a48541689aed549843791cdba36b8b117a94e1902185b67b13a05cd27b554384c66a72d28aecf1e111
|
7
|
+
data.tar.gz: 8b652526794b49792f82c3bf43ec0777a21de3b4fab1b3d6b36a5fa989b53614c175ddb8534aa1ab17ce0df2fe68e0ee8fb99ea2ffc2a209328135cbf4495bf0
|
data/.travis.yml
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9.3
|
4
3
|
- 2.0.0
|
5
4
|
- 2.1
|
6
5
|
- 2.2.2
|
6
|
+
- 2.2.3
|
7
7
|
- ruby-head
|
8
|
-
- jruby-19mode
|
9
8
|
- rbx-2
|
10
9
|
matrix:
|
11
10
|
allow_failures:
|
12
11
|
- rvm: ruby-head
|
13
|
-
- rvm: jruby-19mode
|
14
12
|
- rvm: rbx-2
|
15
13
|
before_install: gem install bundler -v 1.10.5
|
16
14
|
script:
|
data/README.md
CHANGED
@@ -1,12 +1,19 @@
|
|
1
1
|
# Capistrano::Hook
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/capistrano-hook.svg)](http://badge.fury.io/rb/capistrano-hook)
|
4
|
-
[![Build Status](https://travis-ci.org/yulii/capistrano-hook.svg)](https://travis-ci.org/yulii/capistrano-hook)
|
4
|
+
[![Build Status](https://travis-ci.org/yulii/capistrano-hook.svg?branch=master)](https://travis-ci.org/yulii/capistrano-hook)
|
5
5
|
[![Code Climate](https://codeclimate.com/github/yulii/capistrano-hook/badges/gpa.svg)](https://codeclimate.com/github/yulii/capistrano-hook)
|
6
6
|
[![Dependency Status](https://gemnasium.com/yulii/capistrano-hook.svg)](https://gemnasium.com/yulii/capistrano-hook)
|
7
7
|
|
8
8
|
Notification hooks include start, finish and fail of deployments.
|
9
9
|
|
10
|
+
## Features
|
11
|
+
|
12
|
+
### Webhoook
|
13
|
+
|
14
|
+
Notify Capistrano deployments via webhook API.
|
15
|
+
Just set the webhook URL and message.
|
16
|
+
|
10
17
|
## Installation
|
11
18
|
|
12
19
|
Add this line to your application's Gemfile:
|
@@ -23,7 +30,9 @@ Add this line to your Capfile:
|
|
23
30
|
require 'capistrano/hook'
|
24
31
|
```
|
25
32
|
|
26
|
-
|
33
|
+
### Webhook
|
34
|
+
|
35
|
+
Webhook will not be run with no settings. You can setting the variables shown below.
|
27
36
|
|
28
37
|
```ruby
|
29
38
|
set :webhook_url, 'https://yulii.github.io/services'
|
@@ -34,15 +43,29 @@ set :webhook_reverting_payload, { text: 'Reverting...' }
|
|
34
43
|
set :webhook_rollbacked_payload, { text: 'Rollback has been completed!' }
|
35
44
|
```
|
36
45
|
|
46
|
+
### Testing
|
47
|
+
|
37
48
|
Test your setup by running:
|
49
|
+
|
38
50
|
```
|
39
|
-
|
40
|
-
cap production webhook:
|
41
|
-
|
42
|
-
|
43
|
-
cap production webhook:post:
|
44
|
-
|
51
|
+
# List the webhook configured variables
|
52
|
+
$ cap production webhook:config:list
|
53
|
+
|
54
|
+
# Post a starting message
|
55
|
+
$ cap production webhook:post:starting
|
56
|
+
|
57
|
+
# Post a finished message
|
58
|
+
$ cap production webhook:post:finished
|
45
59
|
|
60
|
+
# Post a failed message
|
61
|
+
$ cap production webhook:post:failed
|
62
|
+
|
63
|
+
# Post a reverting message
|
64
|
+
$ cap production webhook:post:reverting
|
65
|
+
|
66
|
+
# Post a rollbacked message
|
67
|
+
$ cap production webhook:post:rollbacked
|
68
|
+
```
|
46
69
|
|
47
70
|
### Slack
|
48
71
|
|
data/lib/capistrano/hook/web.rb
CHANGED
@@ -13,9 +13,13 @@ module Capistrano
|
|
13
13
|
def post(params)
|
14
14
|
# TODO: rescue / logger
|
15
15
|
http.start do
|
16
|
-
request
|
17
|
-
|
18
|
-
|
16
|
+
http.request(request(params))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def request(params)
|
21
|
+
Net::HTTP::Post.new(uri.path).tap do |o|
|
22
|
+
o.set_form_data(payload: params.to_json)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -1,18 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
set :webhook_reverting_payload, { text: 'Reverting...' }
|
12
|
-
set :webhook_rollbacked_payload, { text: 'Rollback has been completed!' }
|
13
|
-
|
14
|
-
DESC
|
1
|
+
# Capistrano hook will not be run with no settings.
|
2
|
+
#
|
3
|
+
# You can setting the variables shown below.
|
4
|
+
#
|
5
|
+
# set :webhook_url, 'https://yulii.github.io'
|
6
|
+
# set :webhook_starting_payload, { text: 'Now, deploying...' }
|
7
|
+
# set :webhook_finished_payload, { text: 'Deployment has been completed!' }
|
8
|
+
# set :webhook_failed_payload, { text: 'Oops! something went wrong.' }
|
9
|
+
# set :webhook_reverting_payload, { text: 'Reverting...' }
|
10
|
+
# set :webhook_rollbacked_payload, { text: 'Rollback has been completed!' }
|
15
11
|
|
12
|
+
namespace :webhook do
|
16
13
|
def webhook(url, payload)
|
17
14
|
return if url.nil? || payload.nil? || payload.empty?
|
18
15
|
info "POST #{url} payload='#{payload}'"
|
@@ -25,7 +22,28 @@ namespace :webhook do
|
|
25
22
|
end
|
26
23
|
end
|
27
24
|
|
25
|
+
namespace :config do
|
26
|
+
desc 'List the webhook configured variables'
|
27
|
+
task :list do
|
28
|
+
run_locally do
|
29
|
+
keys = [:webhook_url,
|
30
|
+
:webhook_starting_payload,
|
31
|
+
:webhook_finished_payload,
|
32
|
+
:webhook_failed_payload,
|
33
|
+
:webhook_reverting_payload,
|
34
|
+
:webhook_rollbacked_payload
|
35
|
+
].sort
|
36
|
+
padding = keys.max { |a, b| a.length <=> b.length }.length
|
37
|
+
keys.each do |key|
|
38
|
+
next if fetch(key).nil? || fetch(key).empty?
|
39
|
+
puts ":#{key.to_s.ljust(padding)} => #{fetch(key)}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
28
45
|
namespace :post do
|
46
|
+
desc 'Post a starting message if :webhook_url and :webhook_starting_payload are present'
|
29
47
|
task :starting do
|
30
48
|
run_locally do
|
31
49
|
url = fetch(:webhook_url)
|
@@ -34,6 +52,7 @@ namespace :webhook do
|
|
34
52
|
end
|
35
53
|
end
|
36
54
|
|
55
|
+
desc 'Post a finished message if :webhook_url and :webhook_finished_payload are present'
|
37
56
|
task :finished do
|
38
57
|
run_locally do
|
39
58
|
url = fetch(:webhook_url)
|
@@ -42,6 +61,7 @@ namespace :webhook do
|
|
42
61
|
end
|
43
62
|
end
|
44
63
|
|
64
|
+
desc 'Post a failed message if :webhook_url and :webhook_failed_payload are present'
|
45
65
|
task :failed do
|
46
66
|
run_locally do
|
47
67
|
url = fetch(:webhook_url)
|
@@ -50,6 +70,7 @@ namespace :webhook do
|
|
50
70
|
end
|
51
71
|
end
|
52
72
|
|
73
|
+
desc 'Post a reverting message if :webhook_url and :webhook_reverting_payload are present'
|
53
74
|
task :reverting do
|
54
75
|
run_locally do
|
55
76
|
url = fetch(:webhook_url)
|
@@ -58,6 +79,7 @@ namespace :webhook do
|
|
58
79
|
end
|
59
80
|
end
|
60
81
|
|
82
|
+
desc 'Post a rollbacked message if :webhook_url and :webhook_rollbacked_payload are present'
|
61
83
|
task :rollbacked do
|
62
84
|
run_locally do
|
63
85
|
url = fetch(:webhook_url)
|
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.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- yulii
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capistrano
|