lita-bamboo 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 929c2a550325fd5044dc905b63ea5efb0cf7ba5c
4
- data.tar.gz: 41785162df2289c184cf7b6313d38daa1d612b98
3
+ metadata.gz: b32f91efad6d5c1feb644b160f9b3c1e8ad9f05a
4
+ data.tar.gz: 46125daa47d0587f0989467e80bf9cea553dc453
5
5
  SHA512:
6
- metadata.gz: 5386c62d18875df5bbc88aa2e2d3f4ac3f07e578db12c9fcebc14e22943f97bf84cfc58f2ff9e109240261621115deb9fcfa25495fc9f9d5b632662d4fe6f48e
7
- data.tar.gz: c11489500274134d75de4393eb3dc82910764f8c82f0ecbc607782e4b3add682df8f1fb130c79cc2b9cc70f7a47ccd924c03b338384942b19903eb013f963530
6
+ metadata.gz: 30ec9e07bbfc04bd642dfd470e05dac71e5f44f649122dfbaf02e8ee645ce0fb6dededb55f43167884160802db141e68dd67c76382370993a1cc8f8d2d7f5abc
7
+ data.tar.gz: 824abba275eb7b1a0a59ac9191852d8a579267b422f0b1e1436716e4d2e2b661f95d3e0c3ca56b42dd06fa93e46bb90d8e33982197c154adb8afda22336d3c49
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # lita-bamboo Change Log
2
2
 
3
+ ### v0.1.4
4
+ * show server info
5
+ * get build result labels, add label to and remove label from build results. (Experimental)
6
+
3
7
  ### v0.1.3
4
8
  * list queue not proper output when queue is empty
5
9
  * Now when plan is queued successfully, show response with message
data/README.md CHANGED
@@ -26,3 +26,7 @@ end
26
26
  * bamboo list queue
27
27
  * bamboo queue PLAN_KEY
28
28
  * bamboo dequeue BUILD_KEY
29
+ * bamboo info
30
+ * bamboo get labels BUILD_KEY
31
+ * bamboo add label LABEL to BUILD_KEY
32
+ * bamboo delete label LABLE from BUILD_KEY
@@ -108,5 +108,62 @@ module LitaBambooHelper
108
108
  end
109
109
  info.to_s
110
110
  end
111
+
112
+ def get_server_info
113
+ url = "#{config.url}/info.json?os_authType=basic"
114
+ info = {}
115
+ begin
116
+ response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get, user: config.user, password: config.password)
117
+ info = JSON.parse(response)
118
+ rescue Exception=>e
119
+ raise "Error to get server info :#{e.message}"
120
+ end
121
+ end
122
+
123
+ def get_server_version
124
+ info = get_server_info
125
+ info['version']
126
+ end
127
+
128
+ def get_build_labels(build_id)
129
+ url = "#{config.url}/result/#{build_id}/label.json"
130
+ info = []
131
+ begin
132
+ response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
133
+ json_response = JSON.parse(response)
134
+ if json_response['labels']['label']
135
+ json_response['labels']['label'].each do |result|
136
+ info << "[#{result['name']}]"
137
+ end
138
+ end
139
+ rescue Exception=>e
140
+ raise "Error to list build queue :#{e.message}"
141
+ end
142
+ info.join(',')
143
+ end #def
144
+
145
+ def add_build_label(build_id, label)
146
+ url = "#{config.url}/result/#{build_id}/label"
147
+ payload = {'name' => "#{label}"}
148
+ headers = {'Content-Type'=> 'application/json'}
149
+ info = []
150
+ begin
151
+ RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :post, :payload =>payload, :headers => headers )
152
+ true
153
+ rescue Exception=>e
154
+ raise "Error to add label to build result :#{e.message}"
155
+ end
156
+ end #def
157
+
158
+ def delete_build_label(build_id, label)
159
+ url = "#{config.url}/result/#{build_id}/#{label}"
160
+ begin
161
+ RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :delete )
162
+ true
163
+ rescue Exception=>e
164
+ raise "Error to delete label from build result :#{e.message}"
165
+ end
166
+ end #def
167
+
111
168
  end #module
112
169
  end
@@ -64,6 +64,43 @@ module Lita
64
64
  }
65
65
  )
66
66
 
67
+ route(
68
+ /^bamboo\s+get\s+label[s]?\s+(\S+)\s*$/,
69
+ :cmd_get_labels,
70
+ command: true,
71
+ help: {
72
+ t('help.cmd_get_labels_key') => t('help.cmd_get_labels_value')
73
+ }
74
+ )
75
+
76
+ route(
77
+ /^bamboo\s+add\s+label\s+(\S+)\s+to\s+(\S+)\s*$/,
78
+ :cmd_add_label,
79
+ command:true,
80
+ help: {
81
+ t('help.cmd_add_label_key') => t('help.cmd_add_label_value')
82
+ }
83
+ )
84
+
85
+ route(
86
+ /^bamboo\s+delete\s+label\s+(\S+)\s+from\s+(\S+)\s*$/,
87
+ :cmd_delete_label,
88
+ command:true,
89
+ help: {
90
+ t('help.cmd_add_label_key') => t('help.cmd_add_label_value')
91
+ }
92
+ )
93
+
94
+ route(
95
+ /^bamboo\s+info\s*$/,
96
+ :cmd_get_info,
97
+ command: true,
98
+ help: {
99
+ t('help_cmd_get_info_key') => t('help_cmd_get_info_value')
100
+ }
101
+
102
+ )
103
+
67
104
  def cmd_list_projects(response)
68
105
  begin
69
106
  info = list_projects
@@ -129,6 +166,55 @@ module Lita
129
166
  end
130
167
  end
131
168
 
169
+ def cmd_get_labels(response)
170
+ build_id = response.matches[0][0]
171
+ begin
172
+ info = get_build_labels(build_id)
173
+ response.reply info
174
+ rescue Exception => e
175
+ response.reply e.message
176
+ end
177
+ end
178
+
179
+ def cmd_add_label(response)
180
+ build_id = response.matches[0][0]
181
+ label = response.matches[0][1]
182
+ begin
183
+ success = add_build_label(build_id, label)
184
+ if success
185
+ response.reply "Lable set successfully."
186
+ else
187
+ response.reply "Cannot add label to build result."
188
+ end
189
+ rescue Exception => e
190
+ response.reply e.message
191
+ end
192
+ end
193
+
194
+ def cmd_delete_label(response)
195
+ build_id = response.matches[0][0]
196
+ label = response.matches[0][1]
197
+ begin
198
+ success = delete_build_label(build_id, label)
199
+ if success
200
+ response.reply "Lable deleted successfully."
201
+ else
202
+ response.reply "Cannot delete label from build result."
203
+ end
204
+ rescue Exception => e
205
+ response.reply e.message
206
+ end
207
+ end
208
+
209
+ def cmd_get_info(response)
210
+ begin
211
+ info = get_server_info
212
+ response.reply info.to_s
213
+ rescue Exception => e
214
+ response.reply e.message
215
+ end
216
+ end
217
+
132
218
  Lita.register_handler(self)
133
219
 
134
220
  end
data/lita-bamboo.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-bamboo"
3
- spec.version = "0.1.3"
3
+ spec.version = "0.1.4"
4
4
  spec.authors = ["Wang, Dawei"]
5
5
  spec.email = ["dwang@entertainment.com"]
6
6
  spec.description = "Bamboo Lita tasks"
data/locales/en.yml CHANGED
@@ -15,3 +15,9 @@ en:
15
15
  cmd_queue_plan_value: 'Queue plan for build'
16
16
  cmd_dequeue_plan_key: 'bamboo dequeue BUILD_KEY'
17
17
  cmd_dequeue_plan_value: 'Dequeue plan from build'
18
+ cmd_get_labels_key: 'bamboo get labels BUILD_KEY'
19
+ cmd_get_labels_value: 'List build labels'
20
+ cmd_get_info_key: 'bamboo info'
21
+ cmd_get_info_value: 'Show bamboo server info'
22
+ cmd_add_label_key: 'bamboo add label LABEL to BUILD_KEY'
23
+ cmd_add_label_value: 'Add label to build result'
@@ -14,6 +14,10 @@ describe Lita::Handlers::Bamboo, lita_handler: true do
14
14
  is_expected.to route_command('bamboo list queue').to(:cmd_list_queue)
15
15
  is_expected.to route_command('bamboo queue PM-RVMGEMSET').to(:cmd_queue_plan)
16
16
  is_expected.to route_command('bamboo dequeue PM-RVMGEMSET-8').to(:cmd_dequeue_plan)
17
+ is_expected.to route_command('bamboo get labels PM-BUILDPM-195').to(:cmd_get_labels)
18
+ is_expected.to route_command('bamboo info').to(:cmd_get_info)
19
+ is_expected.to route_command('bamboo add label LABLE1 to GE-BUILD-1').to(:cmd_add_label)
20
+ is_expected.to route_command('bamboo delete label LABLE1 from GE-BUILD-1').to(:cmd_delete_label)
17
21
  end
18
22
 
19
23
  describe '#get all project list' do
@@ -43,33 +47,41 @@ describe Lita::Handlers::Bamboo, lita_handler: true do
43
47
  end
44
48
  end
45
49
 
46
- describe '#get project plan results' do
47
- #let(:robot) { Lita::Robot.new(registry) }
48
- it 'fecth list of plan build results' do
49
- send_command('bamboo list plan AG-FPMWIL results limit 2')
50
- puts replies.last
51
- #expect(replies.last).to match(/repositoryPath/)
52
- end
53
- end
54
-
55
- describe '#get build queue' do
50
+ describe '#manage build queue' do
56
51
  it 'list build queue' do
57
52
  send_command('bamboo list queue')
58
53
  puts replies.last
59
54
  end
60
- end
61
-
62
- describe '#queue plan for build' do
63
55
  it 'queue plan' do
64
56
  send_command('bamboo queue PM-RVMGEMSET')
65
57
  puts replies.last
66
58
  end
67
- end
68
-
69
- describe '#dequeue plan from build' do
70
59
  it 'dequeue plan' do
71
60
  send_command('bamboo dequeue PORJ-PLAN-8')
72
61
  puts replies.last
73
62
  end
74
63
  end
64
+
65
+ describe '#get server info' do
66
+ it 'show server info' do
67
+ send_command('bamboo info')
68
+ puts replies.last
69
+ end
70
+ end
71
+
72
+ describe '#manage bulid label' do
73
+ it 'get build labels' do
74
+ send_command('bamboo get labels PM-BUILDPM-195')
75
+ puts replies.last
76
+ end
77
+ it 'add label to build' do
78
+ send_command('bamboo add label LABEL1 to TEST-PLAN-1')
79
+ puts replies.last
80
+ end
81
+ it 'delete label to build' do
82
+ send_command('bamboo delete label LABEL1 from TEST-PLAN-1')
83
+ puts replies.last
84
+ end
85
+ end
86
+
75
87
  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.3
4
+ version: 0.1.4
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-08-01 00:00:00.000000000 Z
11
+ date: 2016-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita