-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathjenkins_client.rb
57 lines (51 loc) · 1.55 KB
/
jenkins_client.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require_relative 'jenkins_client/action'
require_relative 'jenkins_client/base_action'
require_relative 'jenkins_client/job_action'
require_relative 'jenkins_client/command'
module Lita
module Handlers
class JenkinsClient < Handler
namespace 'jenkins_client'
CONFIGS = {
server_url: String,
server_ip: String,
server_port: String,
proxy_ip: String,
proxy_port: String,
jenkins_path: String,
username: String,
password: String,
password_base64: String,
log_location: String,
log_level: Integer,
timeout: Integer,
ssl: Object,
follow_redirects: Object,
identity_file: String,
cookies: String
}.freeze
CONFIGS.each do |config_name, config_type|
if config_type == Object
config config_name, type: config_type do
validate do |value|
"#{config_name} must be true or false or nil" unless [true, false, nil].include? value
end
end
else
config config_name, type: config_type
end
end
protected
def jenkins_params
CONFIGS.keys.select{|key| config.respond_to?(key)}.map{|key| [key, config.send(key)] }.to_h
end
def client
@client ||= JenkinsApi::Client.new(jenkins_params)
end
end
Lita.register_handler(JenkinsClient)
Lita.register_handler(JenkinsClient::Action)
Lita.register_handler(JenkinsClient::BaseAction)
Lita.register_handler(JenkinsClient::JobAction)
end
end