patriot-workflow-scheduler 0.8.7 → 0.8.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/patriot/command/post_processor.rb +1 -0
- data/lib/patriot/command/post_processor/slack_notification.rb +105 -0
- data/lib/patriot/version.rb +1 -1
- data/skel/public/views/index.erb +13 -0
- metadata +45 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 873e47de8e691858e4cd97606ac39176468ace3a
|
4
|
+
data.tar.gz: defbffdf2959fad4c3023ccf1cef7cdf2299ee6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2330450116d18236489aa2c8191924c6b933f114108b0a2b5c5c78b68e1052672a5e74133cf46b8f0c22b7aa0c46e5e281b469803ae6c2adddc23470d4813686
|
7
|
+
data.tar.gz: e24ffa5892b4979243ccbba74d855085a0612ca2d03263f4d359949890950beecef38d4fb54435984bc6bbdcd7fc5d1ce811aaefb10ca64862c15b772adfd383
|
@@ -10,6 +10,7 @@ module Patriot
|
|
10
10
|
require 'patriot/command/post_processor/retrial'
|
11
11
|
require 'patriot/command/post_processor/mail_notification'
|
12
12
|
require 'patriot/command/post_processor/http_notification'
|
13
|
+
require 'patriot/command/post_processor/slack_notification'
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
# usage:
|
5
|
+
# slack_notification api_key: slack_api_key, channel: slack_channel, username: username(any), on: 'failed'
|
6
|
+
# slack_notification api_key: slack_api_key, channel: slack_channel, username: username(any), on: ['succeeded', 'failed']
|
7
|
+
module Patriot
|
8
|
+
module Command
|
9
|
+
module PostProcessor
|
10
|
+
class SlackNotification < Patriot::Command::PostProcessor::Base
|
11
|
+
API_KEY = :api_key
|
12
|
+
CHANNEL = :channel
|
13
|
+
USERNAME = :username
|
14
|
+
ON_PROP_KEY = :on
|
15
|
+
|
16
|
+
# retrial
|
17
|
+
COUNT_PROP_KEY = :count
|
18
|
+
|
19
|
+
declare_post_processor_name :slack_notification
|
20
|
+
|
21
|
+
def validate_props(props)
|
22
|
+
raise "#{API_KEY} is not specified" unless props.has_key?(API_KEY)
|
23
|
+
raise "#{CHANNEL} is not specified" unless props.has_key?(CHANNEL)
|
24
|
+
raise "#{USERNAME} is not specified" unless props.has_key?(USERNAME)
|
25
|
+
raise "#{ON_PROP_KEY} is not specified" unless props.has_key?(ON_PROP_KEY)
|
26
|
+
end
|
27
|
+
|
28
|
+
def process(cmd, worker, job_ticket)
|
29
|
+
if should_notice?(cmd, job_ticket)
|
30
|
+
http_request(job_ticket, Patriot::Command::ExitCode.name_of(job_ticket.exit_code), url(worker))
|
31
|
+
end
|
32
|
+
return true
|
33
|
+
end
|
34
|
+
|
35
|
+
def url(worker)
|
36
|
+
return worker.config.get("slack.notification.#{@props[API_KEY]}.url")
|
37
|
+
end
|
38
|
+
|
39
|
+
def should_notice?(cmd, job_ticket)
|
40
|
+
on = @props[ON_PROP_KEY]
|
41
|
+
on = [on] unless on.is_a?(Array)
|
42
|
+
on = on.map{|o| Patriot::Command::ExitCode.value_of(o)}
|
43
|
+
|
44
|
+
if on.include?(job_ticket.exit_code)
|
45
|
+
if Patriot::Command::ExitCode.name_of(job_ticket.exit_code) == 'SUCCEEDED'
|
46
|
+
return true
|
47
|
+
else
|
48
|
+
retrial = cmd.post_processors.select{|pp| pp.is_a?(Patriot::Command::PostProcessor::Retrial)}[0]
|
49
|
+
if retrial == nil || retrial.props[COUNT_PROP_KEY] <= 1
|
50
|
+
return true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
return false
|
56
|
+
end
|
57
|
+
|
58
|
+
def http_request(job_ticket, state, url)
|
59
|
+
icon_emoji = {}
|
60
|
+
icon_emoji['SUCCEEDED'] = ':good:'
|
61
|
+
icon_emoji['FAILED'] = ':no_good:'
|
62
|
+
|
63
|
+
retries = 0
|
64
|
+
begin
|
65
|
+
return RestClient.post(
|
66
|
+
url,
|
67
|
+
{
|
68
|
+
channel: @props[CHANNEL],
|
69
|
+
username: @props[USERNAME],
|
70
|
+
icon_emoji: icon_emoji[state],
|
71
|
+
text: <<-EOT
|
72
|
+
job_id: #{job_ticket.job_id} #{state}!!!
|
73
|
+
|
74
|
+
---
|
75
|
+
exec_host: #{job_ticket.exec_host}
|
76
|
+
#{job_ticket.description}
|
77
|
+
EOT
|
78
|
+
}.to_json,
|
79
|
+
:content_type => 'application/json'
|
80
|
+
)
|
81
|
+
rescue RestClient::Exception => error
|
82
|
+
retries += 1
|
83
|
+
if retries < 3
|
84
|
+
retry
|
85
|
+
else
|
86
|
+
raise error
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def valid_url?(url)
|
92
|
+
begin
|
93
|
+
uri = URI.parse(url)
|
94
|
+
if uri.scheme != 'http' && uri.scheme != 'https'
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
rescue URI::InvalidURIError
|
98
|
+
return false
|
99
|
+
end
|
100
|
+
return true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
data/lib/patriot/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>Patriot Workflow Scheduler</title>
|
4
|
+
<link rel="stylesheet" href="<%= url('css/bootstrap.min.css') %>">
|
5
|
+
<link rel="stylesheet" href="<%= url('css/original.css') %>">
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="mainContent">
|
9
|
+
<script src="<%= url('js/patriot-workflow-scheduler-0.8.0.js') %>"></script>
|
10
|
+
</div>
|
11
|
+
</body>
|
12
|
+
</html>
|
13
|
+
|
metadata
CHANGED
@@ -1,181 +1,181 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patriot-workflow-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Teruyoshi Zenmyo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: log4r
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: json
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.8'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.8'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: inifile
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '2.0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '2.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0.18'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0.18'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rest-client
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '2.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - ~>
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '2.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: sinatra
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - ~>
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '1.4'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - ~>
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '1.4'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: sinatra-contrib
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - ~>
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '1.4'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - ~>
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '1.4'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: mail
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
|
-
- - ~>
|
129
|
+
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '2.6'
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- - ~>
|
136
|
+
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '2.6'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: tilt
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- - ~>
|
143
|
+
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '1.4'
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
|
-
- - ~>
|
150
|
+
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.4'
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: thin
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
|
-
- - ~>
|
157
|
+
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '1.6'
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
|
-
- - ~>
|
164
|
+
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '1.6'
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: rack-rewrite
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
|
-
- - ~>
|
171
|
+
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '1.5'
|
174
174
|
type: :runtime
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
|
-
- - ~>
|
178
|
+
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '1.5'
|
181
181
|
description: a workflow scheduler enabling fine-grained dependency management
|
@@ -186,30 +186,35 @@ executables:
|
|
186
186
|
extensions: []
|
187
187
|
extra_rdoc_files: []
|
188
188
|
files:
|
189
|
+
- bin/patriot
|
190
|
+
- bin/patriot-init
|
191
|
+
- lib/patriot.rb
|
192
|
+
- lib/patriot/command.rb
|
189
193
|
- lib/patriot/command/base.rb
|
190
194
|
- lib/patriot/command/command_group.rb
|
191
195
|
- lib/patriot/command/command_macro.rb
|
192
196
|
- lib/patriot/command/composite.rb
|
193
197
|
- lib/patriot/command/parser.rb
|
198
|
+
- lib/patriot/command/post_processor.rb
|
194
199
|
- lib/patriot/command/post_processor/base.rb
|
195
200
|
- lib/patriot/command/post_processor/discard_on_fail.rb
|
196
201
|
- lib/patriot/command/post_processor/http_notification.rb
|
197
202
|
- lib/patriot/command/post_processor/mail_notification.rb
|
198
203
|
- lib/patriot/command/post_processor/retrial.rb
|
199
204
|
- lib/patriot/command/post_processor/skip_on_fail.rb
|
200
|
-
- lib/patriot/command/post_processor.rb
|
205
|
+
- lib/patriot/command/post_processor/slack_notification.rb
|
201
206
|
- lib/patriot/command/sh_command.rb
|
202
|
-
- lib/patriot/
|
207
|
+
- lib/patriot/controller.rb
|
203
208
|
- lib/patriot/controller/package_controller.rb
|
204
209
|
- lib/patriot/controller/worker_admin_controller.rb
|
205
|
-
- lib/patriot/
|
210
|
+
- lib/patriot/job_store.rb
|
206
211
|
- lib/patriot/job_store/base.rb
|
207
212
|
- lib/patriot/job_store/factory.rb
|
208
213
|
- lib/patriot/job_store/in_memory_store.rb
|
209
214
|
- lib/patriot/job_store/job.rb
|
210
215
|
- lib/patriot/job_store/job_ticket.rb
|
211
216
|
- lib/patriot/job_store/rdb_job_store.rb
|
212
|
-
- lib/patriot/
|
217
|
+
- lib/patriot/tool.rb
|
213
218
|
- lib/patriot/tool/batch_parser.rb
|
214
219
|
- lib/patriot/tool/patriot_command.rb
|
215
220
|
- lib/patriot/tool/patriot_commands/execute.rb
|
@@ -220,38 +225,36 @@ files:
|
|
220
225
|
- lib/patriot/tool/patriot_commands/validate.rb
|
221
226
|
- lib/patriot/tool/patriot_commands/worker.rb
|
222
227
|
- lib/patriot/tool/patriot_commands/worker_admin.rb
|
223
|
-
- lib/patriot/
|
228
|
+
- lib/patriot/util.rb
|
229
|
+
- lib/patriot/util/config.rb
|
224
230
|
- lib/patriot/util/config/base.rb
|
225
231
|
- lib/patriot/util/config/inifile_config.rb
|
226
|
-
- lib/patriot/util/config.rb
|
227
232
|
- lib/patriot/util/cron_format_parser.rb
|
228
233
|
- lib/patriot/util/date_util.rb
|
234
|
+
- lib/patriot/util/db_client.rb
|
229
235
|
- lib/patriot/util/db_client/base.rb
|
230
236
|
- lib/patriot/util/db_client/hash_record.rb
|
231
237
|
- lib/patriot/util/db_client/record.rb
|
232
|
-
- lib/patriot/util/
|
238
|
+
- lib/patriot/util/logger.rb
|
233
239
|
- lib/patriot/util/logger/facade.rb
|
234
240
|
- lib/patriot/util/logger/factory.rb
|
235
241
|
- lib/patriot/util/logger/log4r_factory.rb
|
236
242
|
- lib/patriot/util/logger/webrick_log_factory.rb
|
237
|
-
- lib/patriot/util/logger.rb
|
238
243
|
- lib/patriot/util/param.rb
|
239
244
|
- lib/patriot/util/retry.rb
|
240
245
|
- lib/patriot/util/script.rb
|
241
246
|
- lib/patriot/util/system.rb
|
242
|
-
- lib/patriot/util.rb
|
243
247
|
- lib/patriot/version.rb
|
248
|
+
- lib/patriot/worker.rb
|
244
249
|
- lib/patriot/worker/base.rb
|
245
250
|
- lib/patriot/worker/info_server.rb
|
246
251
|
- lib/patriot/worker/job_store_server.rb
|
247
252
|
- lib/patriot/worker/multi_node_worker.rb
|
253
|
+
- lib/patriot/worker/servlet.rb
|
248
254
|
- lib/patriot/worker/servlet/api_servlet_base.rb
|
249
255
|
- lib/patriot/worker/servlet/index_servlet.rb
|
250
256
|
- lib/patriot/worker/servlet/job_api_servlet.rb
|
251
257
|
- lib/patriot/worker/servlet/worker_api_servlet.rb
|
252
|
-
- lib/patriot/worker/servlet.rb
|
253
|
-
- lib/patriot/worker.rb
|
254
|
-
- lib/patriot.rb
|
255
258
|
- skel/batch/sample/daily/test.pbc
|
256
259
|
- skel/config/patriot.ini
|
257
260
|
- skel/public/css/bootstrap.css
|
@@ -274,9 +277,8 @@ files:
|
|
274
277
|
- skel/public/templates/jobs_deleted.erb
|
275
278
|
- skel/public/templates/layout.erb
|
276
279
|
- skel/public/templates/state_updated.erb
|
280
|
+
- skel/public/views/index.erb
|
277
281
|
- skel/public/views/index.tpl.erb
|
278
|
-
- bin/patriot
|
279
|
-
- bin/patriot-init
|
280
282
|
homepage: http://github.com/CyberAgent/patriot-workflow-scheduler
|
281
283
|
licenses:
|
282
284
|
- Apache-2.0
|
@@ -287,17 +289,17 @@ require_paths:
|
|
287
289
|
- lib
|
288
290
|
required_ruby_version: !ruby/object:Gem::Requirement
|
289
291
|
requirements:
|
290
|
-
- -
|
292
|
+
- - ">="
|
291
293
|
- !ruby/object:Gem::Version
|
292
294
|
version: '0'
|
293
295
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
294
296
|
requirements:
|
295
|
-
- -
|
297
|
+
- - ">="
|
296
298
|
- !ruby/object:Gem::Version
|
297
299
|
version: '0'
|
298
300
|
requirements: []
|
299
301
|
rubyforge_project: patriot-workflow-scheduler
|
300
|
-
rubygems_version: 2.
|
302
|
+
rubygems_version: 2.5.1
|
301
303
|
signing_key:
|
302
304
|
specification_version: 4
|
303
305
|
summary: Patriot Workflow Scheduler
|