rundock-plugin-hook-slack 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +74 -0
- data/Rakefile +30 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/circle.yml +7 -0
- data/lib/rundock/plugin/hook/slack.rb +29 -0
- data/lib/rundock/plugin/hook/slack/version.rb +9 -0
- data/rundock-plugin-hook-slack.gemspec +25 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 69f26642f52530fd037c48c4d8281bea32746414
|
4
|
+
data.tar.gz: b9b30b2bb29d3f5dd68e3e14f6eb1379b92b08c2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6ab378642413f1abc24cbe6469606d4b0dfd4c231dc6a224579999eefdc734ca853af75dddf20be4a5fe513834d720bb1da7be772e6873d810755c02c88c0345
|
7
|
+
data.tar.gz: 2312f20f964303e83979e11873f851369b816b55043f6037d24a9fddca489496883c57ee0772cf8a8f703b95a24698ae64c1a0c5c90120250ffe7f81727b573c
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
Gemfile.lock
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 hiracy
|
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,74 @@
|
|
1
|
+
# Rundock::Plugin::Hook::Slack
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/rundock-plugin-hook-slack.svg)](http://badge.fury.io/rb/rundock-plugin-hook-slack)
|
3
|
+
<!--
|
4
|
+
[![Circle CI](https://circleci.com/gh/hiracy/rundock-plugin-hook-slack/tree/master.png?style=shield)](https://circleci.com/gh/hiracy/rundock-plugin-hook-slack/tree/master)
|
5
|
+
-->
|
6
|
+
|
7
|
+
[Rundock](https://github.com/hiracy/rundock) plugin for [slack API](https://api.slack.com/) hook.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
```
|
12
|
+
$ gem install rundock
|
13
|
+
```
|
14
|
+
|
15
|
+
```
|
16
|
+
$ gem install rundock-plugin-hook-slack
|
17
|
+
```
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Edit your operation scenario to hooks.yml like this sample.
|
22
|
+
|
23
|
+
```
|
24
|
+
my_slack_channel: # hook name
|
25
|
+
hook_type: slack # hook_type(always specify 'slack')
|
26
|
+
# You can use chat.postMesasge Arguments(https://api.slack.com/methods/chat.postMessage)
|
27
|
+
token: xxxx-9999999999-999999999-99999 # token argument(required)
|
28
|
+
channel: my_channel # channel argument(required)
|
29
|
+
username: rundock-bot # username(optional)
|
30
|
+
icon_url: http:/icon.org/rundock-bot.png # icon_url(optional)
|
31
|
+
# :
|
32
|
+
sub_slack_channel:
|
33
|
+
hook_type: slack
|
34
|
+
token: xxxx-1111111111-999999999-99999
|
35
|
+
channel: sub_channel
|
36
|
+
```
|
37
|
+
|
38
|
+
And edit your operation scenario to "[scenario.yml](https://github.com/hiracy/rundock/blob/master/scenario_sample.yml)" like this sample.
|
39
|
+
|
40
|
+
```
|
41
|
+
- node: anyhost-01
|
42
|
+
deploy:
|
43
|
+
- src: /path/to/great/middleware/conf_src.rb # deploy source file from localhost
|
44
|
+
dst: /path/to/great/middleware/conf_dst.rb # deploy destination file to remotehost
|
45
|
+
command:
|
46
|
+
- /etc/init.d/great_middleware start
|
47
|
+
hook:
|
48
|
+
- my_slack_channel # enable hook(hooks.yml/my_slack_channel)
|
49
|
+
- sub_slack_channel
|
50
|
+
---
|
51
|
+
anyhost-01: # see rundock options(https://github.com/hiracy/rundock/blob/master/README.md)
|
52
|
+
host: 192.168.10.11
|
53
|
+
ssh_opts:
|
54
|
+
port: 22
|
55
|
+
user: anyuser
|
56
|
+
key: ~/.ssh/id_rsa
|
57
|
+
```
|
58
|
+
|
59
|
+
and execute rundock.
|
60
|
+
|
61
|
+
$ rundock do /path/to/your-dir/scenario.yml -k /path/to/your-dir/hooks.yml
|
62
|
+
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
1. Fork it ( https://github.com/[my-github-username]/rundock-plugin-operation-itamae/fork )
|
66
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
67
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
68
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
69
|
+
5. Create a new Pull Request
|
70
|
+
|
71
|
+
## License
|
72
|
+
|
73
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
74
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
|
3
|
+
TOKEN_FILE = "#{Dir.home}/.rundock/slack.token"
|
4
|
+
|
5
|
+
task :default => [:spec]
|
6
|
+
|
7
|
+
desc 'Run all tests.'
|
8
|
+
task :spec => ['setup', 'rundock']
|
9
|
+
|
10
|
+
desc 'Setup environments'
|
11
|
+
|
12
|
+
task :setup do
|
13
|
+
Bundler.with_clean_env do
|
14
|
+
unless FileTest.exist?(TOKEN_FILE)
|
15
|
+
puts "#{TOKEN_FILE} not found."
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
token = File.read(TOKEN_FILE)
|
19
|
+
src = File.read('./spec/integration/hooks.yml')
|
20
|
+
File.write("#{Dir.home}/.rundock/rundock-plugin-hook-slack-hooks.yml", src.gsub(/<SLACK_TOKEN>/, token.strip))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Run rundock-slack plugin"
|
25
|
+
|
26
|
+
task :rundock do
|
27
|
+
cmd = "bundle exec rundock do ./spec/integration/scenario.yml -k #{Dir.home}/.rundock/rundock-plugin-hook-slack-hooks.yml -l debug"
|
28
|
+
puts "[EXEC: ] #{cmd}"
|
29
|
+
system cmd
|
30
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "rundock/plugin/hook/slack"
|
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
data/circle.yml
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "rundock/plugin/hook/slack/version"
|
2
|
+
require 'slack'
|
3
|
+
|
4
|
+
module Rundock
|
5
|
+
module Hook
|
6
|
+
class Slack < Base
|
7
|
+
def hook(operation_attributes, log_buffer)
|
8
|
+
|
9
|
+
::Slack.configure do |config|
|
10
|
+
config.token = @contents[:token]
|
11
|
+
end
|
12
|
+
|
13
|
+
@contents[:channel] = '#' + @contents[:channel]
|
14
|
+
Logger.info("send slack to #{@contents[:channel]} channel")
|
15
|
+
post_args = @contents.dup.reject {|k, v| k == :token}
|
16
|
+
|
17
|
+
out_msg = ''
|
18
|
+
log_buffer.each do |log|
|
19
|
+
out_msg += log.formatted_message + "\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
Logger.debug("post args: #{post_args.to_s}")
|
23
|
+
|
24
|
+
post_args[:text] = out_msg
|
25
|
+
::Slack.chat_postMessage(post_args) unless operation_attributes[0][:dry_run]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'rundock/plugin/hook/slack/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "rundock-plugin-hook-slack"
|
8
|
+
spec.version = Rundock::Plugin::Hook::Slack::VERSION
|
9
|
+
spec.authors = ["hiracy"]
|
10
|
+
spec.email = ["leizhen@mbr.nifty.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{rundock plugin for slack API hook}
|
13
|
+
spec.homepage = 'https://github.com/hiracy/rundock-plugin-hook-slack'
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rundock'
|
24
|
+
spec.add_runtime_dependency 'slack-api'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rundock-plugin-hook-slack
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hiracy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rundock
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slack-api
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- leizhen@mbr.nifty.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- bin/console
|
82
|
+
- bin/setup
|
83
|
+
- circle.yml
|
84
|
+
- lib/rundock/plugin/hook/slack.rb
|
85
|
+
- lib/rundock/plugin/hook/slack/version.rb
|
86
|
+
- rundock-plugin-hook-slack.gemspec
|
87
|
+
homepage: https://github.com/hiracy/rundock-plugin-hook-slack
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.4.5
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: rundock plugin for slack API hook
|
111
|
+
test_files: []
|