chatopsify 0.0.6 → 0.0.7
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 +4 -4
- data/README.md +7 -0
- data/lib/capistrano/tasks/chatopsify.cap +8 -4
- data/lib/chatopsify/co.rb +5 -4
- data/lib/chatopsify/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d3e35cc917b13e407c723bfc8a553d7473223e9bef9a303d79901a73f3c3101e
|
|
4
|
+
data.tar.gz: 48275bee23cfe021d2837962017453aba49b645c86659c4fbeb39af66bc2605f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4f4d63cad15b583743737c8981d46207c7e38803fbc396226756ae1a117eb23a1d91f0161ea7f803e96fdf449aad93b2feaf29639d0c2d14ae7742448463a3b0
|
|
7
|
+
data.tar.gz: 319578035100502524f43404ee4542e90fe22f918a93aa1ca6b5029ba1609d89d48efe031d218faf63366a5b5e51bb19d1d5d187bc469dc95d92b05ff08a034d
|
data/README.md
CHANGED
|
@@ -49,6 +49,13 @@ set :chatops_channel_id, 'your_channel_id'
|
|
|
49
49
|
...
|
|
50
50
|
```
|
|
51
51
|
|
|
52
|
+
Config deploy success/failure notifications are posted as thread replies to the initial deploy start message.
|
|
53
|
+
|
|
54
|
+
```ruby
|
|
55
|
+
# config/deploy.rb
|
|
56
|
+
set :chatops_use_thread_replies, true
|
|
57
|
+
```
|
|
58
|
+
|
|
52
59
|
### Copyright
|
|
53
60
|
|
|
54
61
|
©rs-phunt
|
|
@@ -6,7 +6,8 @@ namespace :chatops do
|
|
|
6
6
|
if fetch(:chatops_notify_events).include? :started
|
|
7
7
|
info 'Notifying ChatOps of deploy started'
|
|
8
8
|
begin
|
|
9
|
-
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:starting))
|
|
9
|
+
response = Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:starting))
|
|
10
|
+
set :chatops_root_id, response.dig('id') if fetch(:chatops_use_thread_replies)
|
|
10
11
|
rescue StandardError => e
|
|
11
12
|
info "ERROR notify_started: #{e}"
|
|
12
13
|
end
|
|
@@ -23,7 +24,8 @@ namespace :chatops do
|
|
|
23
24
|
if fetch(:chatops_notify_events).include? :finished
|
|
24
25
|
info 'Notifying ChatOps of deploy finished'
|
|
25
26
|
begin
|
|
26
|
-
|
|
27
|
+
root_id = fetch(:chatops_use_thread_replies) ? fetch(:chatops_root_id) : nil
|
|
28
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:success), root_id)
|
|
27
29
|
rescue StandardError => e
|
|
28
30
|
info "ERROR notify_finished: #{e}"
|
|
29
31
|
end
|
|
@@ -33,14 +35,15 @@ namespace :chatops do
|
|
|
33
35
|
after 'deploy:finished', 'chatops:notify_finished'
|
|
34
36
|
# before 'deploy:failed', 'chatops:notify_finished'
|
|
35
37
|
|
|
36
|
-
desc "Notify ChatOps
|
|
38
|
+
desc "Notify ChatOps Failed"
|
|
37
39
|
task :notify_failed do
|
|
38
40
|
set :chatops_time_finished, Time.now
|
|
39
41
|
run_locally do
|
|
40
42
|
if fetch(:chatops_notify_events).include? :failed
|
|
41
43
|
info 'Notifying ChatOps of deploy failed'
|
|
42
44
|
begin
|
|
43
|
-
|
|
45
|
+
root_id = fetch(:chatops_use_thread_replies) ? fetch(:chatops_root_id) : nil
|
|
46
|
+
Chatopsify::Co.call.process(Chatopsify::CoLib.msg_fmt(:failed), root_id)
|
|
44
47
|
rescue StandardError => e
|
|
45
48
|
info "ERROR notify_failed: #{e}"
|
|
46
49
|
end
|
|
@@ -55,6 +58,7 @@ namespace :load do
|
|
|
55
58
|
set :chatops_co_uri, nil
|
|
56
59
|
set :chatops_api_key, nil
|
|
57
60
|
set :chatops_channel_id, nil
|
|
61
|
+
set :chatops_use_thread_replies, false
|
|
58
62
|
|
|
59
63
|
set :local_user, ->{ ENV["USER"] || ENV["LOGNAME"] || ENV["USERNAME"] || `hostname`.strip + '•' + `whoami`.strip || "default_user" }
|
|
60
64
|
set :ip_address, ->{
|
data/lib/chatopsify/co.rb
CHANGED
|
@@ -16,10 +16,10 @@ module Chatopsify
|
|
|
16
16
|
new(*args, &block)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def process(body = nil)
|
|
19
|
+
def process(body = nil, root_id = nil)
|
|
20
20
|
body ||= Chatopsify::CoLib.msg_fmt
|
|
21
21
|
|
|
22
|
-
send_request(body)
|
|
22
|
+
send_request(body, root_id)
|
|
23
23
|
rescue StandardError => e
|
|
24
24
|
puts e.message
|
|
25
25
|
end
|
|
@@ -51,19 +51,20 @@ module Chatopsify
|
|
|
51
51
|
Chatopsify::CoSecurity.call(@api_key).decrypt_string
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
def send_request(msg)
|
|
54
|
+
def send_request(msg, root_id)
|
|
55
55
|
# puts "msg: #{msg}"
|
|
56
56
|
uri = URI(@uri)
|
|
57
57
|
|
|
58
58
|
req = Net::HTTP::Post.new(uri)
|
|
59
59
|
req['authorization'] = "Bearer #{o_api_key}"
|
|
60
60
|
req.content_type = 'application/json'
|
|
61
|
-
req.body = { channel_id: @channel_id, message: msg }.to_json
|
|
61
|
+
req.body = { channel_id: @channel_id, message: msg, root_id: root_id }.to_json
|
|
62
62
|
res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http|
|
|
63
63
|
http.request(req)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
puts "Response: #{res.code} #{res.body}"
|
|
67
|
+
JSON.parse(res.body)
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
def send_delete_request(id = nil)
|
data/lib/chatopsify/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: chatopsify
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- phunt
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: capistrano
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "~>"
|
|
18
|
-
- !ruby/object:Gem::Version
|
|
19
|
-
version: '3.2'
|
|
20
17
|
- - ">="
|
|
21
18
|
- !ruby/object:Gem::Version
|
|
22
19
|
version: 3.2.0
|
|
20
|
+
- - "~>"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '3.2'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
|
-
- - "~>"
|
|
28
|
-
- !ruby/object:Gem::Version
|
|
29
|
-
version: '3.2'
|
|
30
27
|
- - ">="
|
|
31
28
|
- !ruby/object:Gem::Version
|
|
32
29
|
version: 3.2.0
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '3.2'
|
|
33
33
|
description: chatopsify = ChatOps + Capistrano notifications via API
|
|
34
34
|
email:
|
|
35
35
|
- phunt@runsystem.net
|
|
@@ -64,7 +64,7 @@ licenses:
|
|
|
64
64
|
metadata:
|
|
65
65
|
rubygems_mfa_required: 'true'
|
|
66
66
|
changelog_uri: https://github.com/papakvy/chatopsify/blob/master/CHANGELOG.md
|
|
67
|
-
post_install_message:
|
|
67
|
+
post_install_message:
|
|
68
68
|
rdoc_options: []
|
|
69
69
|
require_paths:
|
|
70
70
|
- lib
|
|
@@ -79,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
80
|
version: '0'
|
|
81
81
|
requirements: []
|
|
82
|
-
rubygems_version: 3.
|
|
83
|
-
signing_key:
|
|
82
|
+
rubygems_version: 3.0.3.1
|
|
83
|
+
signing_key:
|
|
84
84
|
specification_version: 4
|
|
85
85
|
summary: Publish deployment notifications to ChatOps via the API
|
|
86
86
|
test_files: []
|