capistrano-hook 0.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 +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +43 -0
- data/.travis.yml +18 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Capfile +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +67 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/rubocop-auto-correct +8 -0
- data/bin/setup +7 -0
- data/capistrano-hook.gemspec +30 -0
- data/config/deploy.rb +44 -0
- data/config/deploy/production.rb +44 -0
- data/config/deploy/staging.rb +61 -0
- data/lib/capistrano/hook.rb +4 -0
- data/lib/capistrano/hook/version.rb +5 -0
- data/lib/capistrano/hook/web.rb +31 -0
- data/lib/capistrano/tasks/webhook.rake +79 -0
- metadata +163 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3bcc558b728d64f19584877152cf868fa05c34e0
|
4
|
+
data.tar.gz: 9d6d9928e189d4d10d5d7c040c7b476e910e8ccd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a0b08c655b908e49deff5fa05ceb0f49bc9a36a3b4810c8d4fd9de8829705ce99fc0b839dcf66356421f367a5a55ab8b191888a9a722e3f689a0684e4896c91e
|
7
|
+
data.tar.gz: dc2432d843a704f4138f2a3b4b8a3552121e189019af6b68fa645187306880d998d72667b892ef0720150faa656a4580993e8e9033dd75fc9f92e7338e554d4c
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
+
# on 2015-07-29 21:24:29 +0900 using RuboCop version 0.32.1.
|
3
|
+
# The point is for the user to remove these configuration records
|
4
|
+
# one by one as the offenses are removed from the code base.
|
5
|
+
# Note that changes in the inspected code, or installation of new
|
6
|
+
# versions of RuboCop, may require this file to be generated again.
|
7
|
+
|
8
|
+
# Offense count: 2
|
9
|
+
# Configuration parameters: AllowURI, URISchemes.
|
10
|
+
Metrics/LineLength:
|
11
|
+
Max: 104
|
12
|
+
|
13
|
+
# Offense count: 1
|
14
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
15
|
+
Style/ClassAndModuleChildren:
|
16
|
+
Enabled: false
|
17
|
+
|
18
|
+
# Offense count: 3
|
19
|
+
Style/Documentation:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
# Offense count: 1
|
23
|
+
# Cop supports --auto-correct.
|
24
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues.
|
25
|
+
Style/HashSyntax:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Offense count: 2
|
29
|
+
# Cop supports --auto-correct.
|
30
|
+
# Configuration parameters: PreferredDelimiters.
|
31
|
+
Style/PercentLiteralDelimiters:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
# Offense count: 20
|
35
|
+
# Cop supports --auto-correct.
|
36
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
37
|
+
Style/StringLiterals:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
# Offense count: 2
|
41
|
+
# Cop supports --auto-correct.
|
42
|
+
Style/UnneededPercentQ:
|
43
|
+
Enabled: false
|
data/.travis.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 1.9.3
|
4
|
+
- 2.0.0
|
5
|
+
- 2.1
|
6
|
+
- 2.2.2
|
7
|
+
- ruby-head
|
8
|
+
- jruby-19mode
|
9
|
+
- rbx-2
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- rvm: ruby-head
|
13
|
+
- rvm: jruby-19mode
|
14
|
+
- rvm: rbx-2
|
15
|
+
before_install: gem install bundler -v 1.10.5
|
16
|
+
script:
|
17
|
+
- bundle exec rake
|
18
|
+
- bundle exec rubocop
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Capfile
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 yulii
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Capistrano::Hook
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'capistrano-hook'
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Add this line to your Capfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'capistrano/hook'
|
17
|
+
```
|
18
|
+
|
19
|
+
Capistrano hook will not be run with no settings. You can setting the variables shown below.
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
set :webhook_url, 'http://hooks.yulii.net/services'
|
23
|
+
set :webhook_starting_payload, { text: 'Now, deploying...' }
|
24
|
+
set :webhook_finished_payload, { text: 'Deployment has been completed!' }
|
25
|
+
set :webhook_failed_payload, { text: 'Oops! something went wrong.' }
|
26
|
+
```
|
27
|
+
|
28
|
+
### Slack
|
29
|
+
|
30
|
+
Create incoming webhooks into Slack.
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
set :webhook_url, 'http://hooks.yulii.net/services'
|
34
|
+
set :webhook_starting_payload, {
|
35
|
+
username: 'Capistrano',
|
36
|
+
icon_emoji: ':monkey_face:',
|
37
|
+
text: 'Now, deploying...'
|
38
|
+
}
|
39
|
+
set :webhook_finished_payload, {
|
40
|
+
username: 'Capistrano',
|
41
|
+
icon_emoji: ':monkey_face:',
|
42
|
+
text: 'Deployment has been completed!'
|
43
|
+
}
|
44
|
+
set :webhook_failed_payload, {
|
45
|
+
username: 'Capistrano',
|
46
|
+
icon_emoji: ':monkey_face:',
|
47
|
+
text: 'Oops! something went wrong.'
|
48
|
+
}
|
49
|
+
```
|
50
|
+
|
51
|
+
[Slack API - Incoming Webhooks](https://api.slack.com/incoming-webhooks)
|
52
|
+
|
53
|
+
## Development
|
54
|
+
|
55
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
56
|
+
|
57
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/yulii/capistrano-hook. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
62
|
+
|
63
|
+
|
64
|
+
## License
|
65
|
+
|
66
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
67
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'capistrano/hook'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/hook/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capistrano-hook'
|
8
|
+
spec.version = Capistrano::Hook::VERSION
|
9
|
+
spec.authors = ['yulii']
|
10
|
+
spec.email = ['yuliinfo@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Simple Hook for Capistrano'
|
13
|
+
spec.description = 'Simple Hook for Capistrano'
|
14
|
+
spec.homepage = 'https://github.com/yulii/capistrano-hook'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = 'exe'
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.add_dependency 'capistrano', '~> 3.1'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'minitest'
|
27
|
+
spec.add_development_dependency 'minitest-reporters'
|
28
|
+
spec.add_development_dependency 'webmock'
|
29
|
+
spec.add_development_dependency 'rubocop'
|
30
|
+
end
|
data/config/deploy.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# config valid only for current version of Capistrano
|
2
|
+
lock '3.4.0'
|
3
|
+
|
4
|
+
set :application, 'capistrano-hook'
|
5
|
+
set :repo_url, 'git@github.com:yulii/capistrano-hook.git'
|
6
|
+
|
7
|
+
# Default branch is :master
|
8
|
+
# ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp
|
9
|
+
|
10
|
+
set :deploy_to, '/tmp'
|
11
|
+
set :scm, :git
|
12
|
+
|
13
|
+
# Default value for :format is :pretty
|
14
|
+
# set :format, :pretty
|
15
|
+
|
16
|
+
# Default value for :log_level is :debug
|
17
|
+
# set :log_level, :debug
|
18
|
+
|
19
|
+
# Default value for :pty is false
|
20
|
+
# set :pty, true
|
21
|
+
|
22
|
+
# Default value for :linked_files is []
|
23
|
+
# set :linked_files, fetch(:linked_files, []).push('config/database.yml', 'config/secrets.yml')
|
24
|
+
|
25
|
+
# Default value for linked_dirs is []
|
26
|
+
# set :linked_dirs, fetch(:linked_dirs, []).push('log', 'tmp/pids', 'tmp/cache', 'tmp/sockets', 'vendor/bundle', 'public/system')
|
27
|
+
|
28
|
+
# Default value for default_env is {}
|
29
|
+
# set :default_env, { path: "/opt/ruby/bin:$PATH" }
|
30
|
+
|
31
|
+
set :keep_releases, 5
|
32
|
+
|
33
|
+
namespace :deploy do
|
34
|
+
|
35
|
+
after :restart, :clear_cache do
|
36
|
+
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
37
|
+
# Here we can do anything such as:
|
38
|
+
# within release_path do
|
39
|
+
# execute :rake, 'cache:clear'
|
40
|
+
# end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# role-based syntax
|
13
|
+
# ==================
|
14
|
+
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
18
|
+
# Don't use `:all`, it's a meta role.
|
19
|
+
|
20
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
21
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
22
|
+
# role :db, %w{deploy@example.com}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Configuration
|
27
|
+
# =============
|
28
|
+
set :webhook_url, 'http://yulii.net/webhook'
|
29
|
+
set :webhook_starting_payload, { text: '[production] Now, deploying...' }
|
30
|
+
set :webhook_finished_payload, { text: '[production] Deployment has been completed!' }
|
31
|
+
set :webhook_failed_payload, { text: '[production] Oops! something went wrong.' }
|
32
|
+
|
33
|
+
# The server-based syntax can be used to override options:
|
34
|
+
# ------------------------------------
|
35
|
+
# server 'example.com',
|
36
|
+
# user: 'user_name',
|
37
|
+
# roles: %w{web app},
|
38
|
+
# ssh_options: {
|
39
|
+
# user: 'user_name', # overrides user setting above
|
40
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
41
|
+
# forward_agent: false,
|
42
|
+
# auth_methods: %w(publickey password)
|
43
|
+
# # password: 'please use keys'
|
44
|
+
# }
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# server-based syntax
|
2
|
+
# ======================
|
3
|
+
# Defines a single server with a list of roles and multiple properties.
|
4
|
+
# You can define all roles on a single server, or split them:
|
5
|
+
|
6
|
+
# server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_value
|
7
|
+
# server 'example.com', user: 'deploy', roles: %w{app web}, other_property: :other_value
|
8
|
+
# server 'db.example.com', user: 'deploy', roles: %w{db}
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
# role-based syntax
|
13
|
+
# ==================
|
14
|
+
|
15
|
+
# Defines a role with one or multiple servers. The primary server in each
|
16
|
+
# group is considered to be the first unless any hosts have the primary
|
17
|
+
# property set. Specify the username and a domain or IP for the server.
|
18
|
+
# Don't use `:all`, it's a meta role.
|
19
|
+
|
20
|
+
# role :app, %w{deploy@example.com}, my_property: :my_value
|
21
|
+
# role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value
|
22
|
+
# role :db, %w{deploy@example.com}
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
# Configuration
|
27
|
+
# =============
|
28
|
+
# You can set any configuration variable like in config/deploy.rb
|
29
|
+
# These variables are then only loaded and set in this stage.
|
30
|
+
# For available Capistrano configuration variables see the documentation page.
|
31
|
+
# http://capistranorb.com/documentation/getting-started/configuration/
|
32
|
+
# Feel free to add new variables to customise your setup.
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
# Custom SSH Options
|
37
|
+
# ==================
|
38
|
+
# You may pass any option but keep in mind that net/ssh understands a
|
39
|
+
# limited set of options, consult the Net::SSH documentation.
|
40
|
+
# http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start
|
41
|
+
#
|
42
|
+
# Global options
|
43
|
+
# --------------
|
44
|
+
# set :ssh_options, {
|
45
|
+
# keys: %w(/home/rlisowski/.ssh/id_rsa),
|
46
|
+
# forward_agent: false,
|
47
|
+
# auth_methods: %w(password)
|
48
|
+
# }
|
49
|
+
#
|
50
|
+
# The server-based syntax can be used to override options:
|
51
|
+
# ------------------------------------
|
52
|
+
# server 'example.com',
|
53
|
+
# user: 'user_name',
|
54
|
+
# roles: %w{web app},
|
55
|
+
# ssh_options: {
|
56
|
+
# user: 'user_name', # overrides user setting above
|
57
|
+
# keys: %w(/home/user_name/.ssh/id_rsa),
|
58
|
+
# forward_agent: false,
|
59
|
+
# auth_methods: %w(publickey password)
|
60
|
+
# # password: 'please use keys'
|
61
|
+
# }
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
module Capistrano
|
3
|
+
module Hook
|
4
|
+
class Web
|
5
|
+
private_class_method :new
|
6
|
+
|
7
|
+
def initialize(url)
|
8
|
+
@uri = URI.parse(url).freeze
|
9
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
10
|
+
@http.use_ssl = @uri.is_a?(URI::HTTPS)
|
11
|
+
end
|
12
|
+
|
13
|
+
def post(params)
|
14
|
+
# TODO: rescue / logger
|
15
|
+
http.start do
|
16
|
+
request = Net::HTTP::Post.new(uri.path)
|
17
|
+
request.set_form_data(payload: params.to_json)
|
18
|
+
http.request(request)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.client(url)
|
23
|
+
new(url)
|
24
|
+
end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
attr_reader :uri, :http
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
namespace :webhook do
|
2
|
+
|
3
|
+
desc <<-DESC
|
4
|
+
Capistrano hook will not be run with no settings.
|
5
|
+
|
6
|
+
You can setting the variables shown below.
|
7
|
+
|
8
|
+
set :webhook_url, 'http://yulii.net/'
|
9
|
+
set :webhook_starting_payload, { text: 'Now, deploying...' }
|
10
|
+
set :webhook_finished_payload, { text: 'Deployment has been completed!' }
|
11
|
+
set :webhook_failed_payload, { text: 'Oops! something went wrong.' }
|
12
|
+
|
13
|
+
DESC
|
14
|
+
|
15
|
+
def response_message(result, params)
|
16
|
+
"POST webhook HTTP #{result.code} #{result.message} body='#{result.body}' payload=#{params}"
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :post do
|
20
|
+
|
21
|
+
task :starting do
|
22
|
+
run_locally do
|
23
|
+
url = fetch(:webhook_url)
|
24
|
+
payload = fetch(:webhook_starting_payload)
|
25
|
+
next if payload.nil? || payload.empty?
|
26
|
+
begin
|
27
|
+
result = Capistrano::Hook::Web.client(url).post(payload)
|
28
|
+
if result.is_a?(Net::HTTPSuccess)
|
29
|
+
info response_message(result, payload)
|
30
|
+
else
|
31
|
+
error response_message(result, payload)
|
32
|
+
end
|
33
|
+
rescue StandardError => e
|
34
|
+
error "[webhook:post:starting] #{e.class} #{e.message}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
task :finished do
|
40
|
+
run_locally do
|
41
|
+
url = fetch(:webhook_url)
|
42
|
+
payload = fetch(:webhook_finished_payload)
|
43
|
+
next if payload.nil? || payload.empty?
|
44
|
+
begin
|
45
|
+
result = Capistrano::Hook::Web.client(url).post(payload)
|
46
|
+
if result.is_a?(Net::HTTPSuccess)
|
47
|
+
info response_message(result, payload)
|
48
|
+
else
|
49
|
+
error response_message(result, payload)
|
50
|
+
end
|
51
|
+
rescue StandardError => e
|
52
|
+
error "[webhook:post:finishing] #{e.class} #{e.message}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
task :failed do
|
58
|
+
run_locally do
|
59
|
+
url = fetch(:webhook_url)
|
60
|
+
payload = fetch(:webhook_failed_payload)
|
61
|
+
next if payload.nil? || payload.empty?
|
62
|
+
begin
|
63
|
+
result = Capistrano::Hook::Web.client(url).post(payload)
|
64
|
+
if result.is_a?(Net::HTTPSuccess)
|
65
|
+
info response_message(result, payload)
|
66
|
+
else
|
67
|
+
error response_message(result, payload)
|
68
|
+
end
|
69
|
+
rescue StandardError => e
|
70
|
+
error "[webhook:post:failed] #{e.class} #{e.message}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
before 'deploy:starting', 'webhook:post:starting'
|
76
|
+
after 'deploy:finishing', 'webhook:post:finished'
|
77
|
+
after 'deploy:failed', 'webhook:post:failed'
|
78
|
+
end
|
79
|
+
end
|
metadata
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-hook
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yulii
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest-reporters
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
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
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Simple Hook for Capistrano
|
112
|
+
email:
|
113
|
+
- yuliinfo@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- ".gitignore"
|
119
|
+
- ".rubocop.yml"
|
120
|
+
- ".rubocop_todo.yml"
|
121
|
+
- ".travis.yml"
|
122
|
+
- CODE_OF_CONDUCT.md
|
123
|
+
- Capfile
|
124
|
+
- Gemfile
|
125
|
+
- LICENSE.txt
|
126
|
+
- README.md
|
127
|
+
- Rakefile
|
128
|
+
- bin/console
|
129
|
+
- bin/rubocop-auto-correct
|
130
|
+
- bin/setup
|
131
|
+
- capistrano-hook.gemspec
|
132
|
+
- config/deploy.rb
|
133
|
+
- config/deploy/production.rb
|
134
|
+
- config/deploy/staging.rb
|
135
|
+
- lib/capistrano/hook.rb
|
136
|
+
- lib/capistrano/hook/version.rb
|
137
|
+
- lib/capistrano/hook/web.rb
|
138
|
+
- lib/capistrano/tasks/webhook.rake
|
139
|
+
homepage: https://github.com/yulii/capistrano-hook
|
140
|
+
licenses:
|
141
|
+
- MIT
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - ">="
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.4.5
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Simple Hook for Capistrano
|
163
|
+
test_files: []
|