lita-bamboo 0.1.1 → 0.1.2
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/CHANGELOG.md +14 -0
- data/README.md +3 -0
- data/lib/bamboohelper/plans.rb +24 -9
- data/lib/lita-bamboo.rb +0 -1
- data/lib/lita/handlers/bamboo.rb +62 -1
- data/lita-bamboo.gemspec +1 -1
- data/locales/en.yml +6 -0
- data/spec/lita/handlers/bamboo_spec.rb +26 -0
- metadata +3 -3
- data/lib/bamboohelper/misc.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7900de87469633c5def0649c70e87a293b2445d4
|
4
|
+
data.tar.gz: 2acfdefa928a86e3326a49677bbb2e1d0b31ec2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70b21815adf6b3f4405b3d87e66336f9fd23841cce4144a1411021e2e5f543e2df19ea587003e14a1152051abf5a203884e8e1b9f25afa5c18ca2d216072b684
|
7
|
+
data.tar.gz: f12dd05405940010d1057375d0b7855ee230a9569e53e263da0509d30d5d51b7d7286dabc16060276c1695481080aa4de14edace946beb30ec3373b4599c8e70
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# lita-bamboo Change Log
|
2
|
+
|
3
|
+
### v0.1.2
|
4
|
+
* list build queue
|
5
|
+
* queue plan for build
|
6
|
+
* dequeue plan from build queue
|
7
|
+
|
8
|
+
### v0.1.1
|
9
|
+
* output changes for list plan and projects
|
10
|
+
|
11
|
+
### v0.1.0
|
12
|
+
* list projects
|
13
|
+
* list plans
|
14
|
+
* list plan build results
|
data/README.md
CHANGED
data/lib/bamboohelper/plans.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
+
require 'rest-client'
|
2
3
|
module LitaBambooHelper
|
3
4
|
module Plan
|
4
5
|
def list_projects
|
@@ -64,32 +65,46 @@ module LitaBambooHelper
|
|
64
65
|
end
|
65
66
|
|
66
67
|
def queue_plan(plan_id)
|
67
|
-
url = "#{config.url}/queue/#{plan_id}"
|
68
|
+
url = "#{config.url}/queue/#{plan_id}?os_authType=basic"
|
68
69
|
begin
|
69
|
-
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :post)
|
70
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :post, user: config.user, password: config.password)
|
70
71
|
if response.code == 200
|
71
72
|
true
|
72
73
|
else
|
73
74
|
false
|
74
75
|
end
|
75
76
|
rescue Exception=>e
|
76
|
-
raise "Error to queue
|
77
|
+
raise "Error to queue plan #{plan_id} for build :#{e.message}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def dequeue_plan(build_id)
|
82
|
+
url = "#{config.url}/queue/#{build_id}?os_authType=basic"
|
83
|
+
begin
|
84
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :delete, user: config.user, password: config.password)
|
85
|
+
if response.code == 200
|
86
|
+
true
|
87
|
+
else
|
88
|
+
false
|
89
|
+
end
|
90
|
+
rescue Exception=>e
|
91
|
+
raise "Error to dequeue plan build #{build_id} :#{e.message}"
|
77
92
|
end
|
78
93
|
end
|
79
94
|
|
80
95
|
def list_queue()
|
81
|
-
url = "#{config.url}/queue?os_authType=basic"
|
96
|
+
url = "#{config.url}/queue.json?os_authType=basic"
|
82
97
|
info = []
|
83
98
|
begin
|
84
|
-
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
|
99
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get, user: config.user, password: config.password)
|
85
100
|
json_response = JSON.parse(response)
|
86
|
-
if json_response['
|
87
|
-
json_response['
|
88
|
-
info << "
|
101
|
+
if json_response['queuedBuilds']['queuedBuild']
|
102
|
+
json_response['queuedBuilds']['queuedBuild'].each do |result|
|
103
|
+
info << "BuildKey: #{result['buildResultKey']} TrigerReason: #{result['triggerReason']} "
|
89
104
|
end
|
90
105
|
end
|
91
106
|
rescue Exception=>e
|
92
|
-
raise "Error to list build
|
107
|
+
raise "Error to list build queue :#{e.message}"
|
93
108
|
end
|
94
109
|
info
|
95
110
|
end
|
data/lib/lita-bamboo.rb
CHANGED
data/lib/lita/handlers/bamboo.rb
CHANGED
@@ -5,8 +5,9 @@ module Lita
|
|
5
5
|
namespace 'Bamboo'
|
6
6
|
config :url, required: true, type: String # https://host:port/rest/api/latest
|
7
7
|
config :verify_ssl, required: true, types: [TrueClass, FalseClass], default: false
|
8
|
+
config :user, required: true, type: String
|
9
|
+
config :password, required: true, type: String
|
8
10
|
|
9
|
-
include ::LitaBambooHelper::Misc
|
10
11
|
include ::LitaBambooHelper::Plan
|
11
12
|
|
12
13
|
route(
|
@@ -36,6 +37,33 @@ module Lita
|
|
36
37
|
}
|
37
38
|
)
|
38
39
|
|
40
|
+
route(
|
41
|
+
/^bamboo\s+list\s+queue\s*$/,
|
42
|
+
:cmd_list_queue,
|
43
|
+
command: true,
|
44
|
+
help: {
|
45
|
+
t('help.cmd_list_queue_key') => t('help.cmd_list_queue_value')
|
46
|
+
}
|
47
|
+
)
|
48
|
+
|
49
|
+
route(
|
50
|
+
/^bamboo\s+queue\s+(\S+)$/,
|
51
|
+
:cmd_queue_plan,
|
52
|
+
command: true,
|
53
|
+
help: {
|
54
|
+
t('help.cmd_queue_plan_key') => t('help.cmd_queue_plan_value')
|
55
|
+
}
|
56
|
+
)
|
57
|
+
|
58
|
+
route(
|
59
|
+
/^bamboo\s+dequeue\s+(\S+)$/,
|
60
|
+
:cmd_dequeue_plan,
|
61
|
+
command: true,
|
62
|
+
help: {
|
63
|
+
t('help.cmd_dequeue_plan_key') => t('help.cmd_dequeue_plan_value')
|
64
|
+
}
|
65
|
+
)
|
66
|
+
|
39
67
|
def cmd_list_projects(response)
|
40
68
|
begin
|
41
69
|
info = list_projects
|
@@ -66,6 +94,39 @@ module Lita
|
|
66
94
|
end
|
67
95
|
end
|
68
96
|
|
97
|
+
def cmd_queue_plan(response)
|
98
|
+
plan_id = response.matches[0][0]
|
99
|
+
begin
|
100
|
+
success = queue_plan(plan_id)
|
101
|
+
unless success
|
102
|
+
response.reply "Failed to queue plan #{plan_id}"
|
103
|
+
end
|
104
|
+
rescue Exception => e
|
105
|
+
response.reply e.message
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def cmd_dequeue_plan(response)
|
110
|
+
build_id = response.matches[0][0]
|
111
|
+
begin
|
112
|
+
success = dequeue_plan(build_id)
|
113
|
+
unless success
|
114
|
+
response.reply "Failed to dequeue plan build #{build_id}"
|
115
|
+
end
|
116
|
+
rescue Exception => e
|
117
|
+
response.reply e.message
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def cmd_list_queue(response)
|
122
|
+
begin
|
123
|
+
info = list_queue
|
124
|
+
response.reply info
|
125
|
+
rescue Exception => e
|
126
|
+
response.reply e.message
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
69
130
|
Lita.register_handler(self)
|
70
131
|
|
71
132
|
end
|
data/lita-bamboo.gemspec
CHANGED
data/locales/en.yml
CHANGED
@@ -9,3 +9,9 @@ en:
|
|
9
9
|
cmd_list_project_plans_value: 'List all plans in project'
|
10
10
|
cmd_list_plan_results_key: 'bamboo list plan LAN_KEY results limit LIMIT'
|
11
11
|
cmd_list_plan_results_value: 'List plan build results last LIMIT'
|
12
|
+
cmd_list_queue_key: 'bamboo list queue'
|
13
|
+
cmd_list_queue_value: 'List what is in current build queue'
|
14
|
+
cmd_queue_plan_key: 'bamboo queue PLAN_KEY'
|
15
|
+
cmd_queue_plan_value: 'Queue plan for build'
|
16
|
+
cmd_dequeue_plan_key: 'bamboo dequeue BUILD_KEY'
|
17
|
+
cmd_dequeue_plan_value: 'Dequeue plan from build'
|
@@ -4,11 +4,16 @@ describe Lita::Handlers::Bamboo, lita_handler: true do
|
|
4
4
|
before do
|
5
5
|
registry.config.handlers.bamboo.url = 'https://bamboo.entertainment.com/rest/api/latest'
|
6
6
|
registry.config.handlers.bamboo.verify_ssl = false
|
7
|
+
registry.config.handlers.bamboo.user = 'dummy'
|
8
|
+
registry.config.handlers.bamboo.password = 'pass'
|
7
9
|
end
|
8
10
|
it do
|
9
11
|
is_expected.to route_command('bamboo list project').to(:cmd_list_projects)
|
10
12
|
is_expected.to route_command('bamboo list project AG plans').to(:cmd_list_project_plans)
|
11
13
|
is_expected.to route_command('bamboo list plan AG-FPMWIL results limit 1').to(:cmd_list_plan_results)
|
14
|
+
is_expected.to route_command('bamboo list queue').to(:cmd_list_queue)
|
15
|
+
is_expected.to route_command('bamboo queue PM-RVMGEMSET').to(:cmd_queue_plan)
|
16
|
+
is_expected.to route_command('bamboo dequeue PM-RVMGEMSET-8').to(:cmd_dequeue_plan)
|
12
17
|
end
|
13
18
|
|
14
19
|
describe '#get all project list' do
|
@@ -46,4 +51,25 @@ describe Lita::Handlers::Bamboo, lita_handler: true do
|
|
46
51
|
#expect(replies.last).to match(/repositoryPath/)
|
47
52
|
end
|
48
53
|
end
|
54
|
+
|
55
|
+
describe '#get build queue' do
|
56
|
+
it 'list build queue' do
|
57
|
+
send_command('bamboo list queue')
|
58
|
+
puts replies.last
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#queue plan for build' do
|
63
|
+
it 'queue plan' do
|
64
|
+
send_command('bamboo queue PM-RVMGEMSET')
|
65
|
+
puts replies.last
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#dequeue plan from build' do
|
70
|
+
it 'dequeue plan' do
|
71
|
+
send_command('bamboo dequeue PORJ-PLAN-8')
|
72
|
+
puts replies.last
|
73
|
+
end
|
74
|
+
end
|
49
75
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-bamboo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wang, Dawei
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -109,10 +109,10 @@ extra_rdoc_files: []
|
|
109
109
|
files:
|
110
110
|
- ".gitignore"
|
111
111
|
- ".rspec"
|
112
|
+
- CHANGELOG.md
|
112
113
|
- Gemfile
|
113
114
|
- README.md
|
114
115
|
- Rakefile
|
115
|
-
- lib/bamboohelper/misc.rb
|
116
116
|
- lib/bamboohelper/plans.rb
|
117
117
|
- lib/lita-bamboo.rb
|
118
118
|
- lib/lita/handlers/bamboo.rb
|