Class: Lita::Handlers::Bamboo

Inherits:
Handler
  • Object
show all
Includes:
LitaBambooHelper::Plan
Defined in:
lib/lita/handlers/bamboo.rb

Instance Method Summary collapse

Methods included from LitaBambooHelper::Plan

#add_build_label, #delete_build_label, #dequeue_plan, #get_build_labels, #get_server_info, #get_server_version, #list_plan_build, #list_project_plan, #list_projects, #list_queue, #pause_server, #prepare_restart, #queue_plan, #resume_server

Instance Method Details

#cmd_add_label(response) ⇒ Object



205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/lita/handlers/bamboo.rb', line 205

def cmd_add_label(response)
  build_id = response.matches[0][0]
  label = response.matches[0][1]
  begin
    success = add_build_label(build_id, label)
    if success
      response.reply "Lable set successfully."
    else
      response.reply "Cannot add label to build result."
    end
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_delete_label(response) ⇒ Object



220
221
222
223
224
225
226
227
228
229
230
231
232
233
# File 'lib/lita/handlers/bamboo.rb', line 220

def cmd_delete_label(response)
  build_id = response.matches[0][0]
  label = response.matches[0][1]
  begin
    success = delete_build_label(build_id, label)
    if success
      response.reply "Lable deleted successfully."
    else
      response.reply "Cannot delete label from build result."
    end
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_dequeue_plan(response) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/lita/handlers/bamboo.rb', line 172

def cmd_dequeue_plan(response)
  build_id = response.matches[0][0]
  begin
    success = dequeue_plan(build_id)
    if success
      response.reply "Plan #{build_id} is queued for build."
    else
      response.reply "Failed to dequeue plan build #{build_id}"
    end
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_get_info(response) ⇒ Object



235
236
237
238
239
240
241
242
# File 'lib/lita/handlers/bamboo.rb', line 235

def cmd_get_info(response)
  begin
    info = get_server_info
    response.reply info.to_s
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_get_labels(response) ⇒ Object



195
196
197
198
199
200
201
202
203
# File 'lib/lita/handlers/bamboo.rb', line 195

def cmd_get_labels(response)
  build_id = response.matches[0][0]
  begin
    info = get_build_labels(build_id)
    response.reply info
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_list_plan_results(response) ⇒ Object



149
150
151
152
153
154
155
156
157
158
# File 'lib/lita/handlers/bamboo.rb', line 149

def cmd_list_plan_results(response)
  plan_id = response.matches[0][0]
  limit = response.matches[0][1]
  begin
    info = list_plan_build(plan_id, Integer(limit))
    response.reply info.join "\n"
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_list_project_plans(response) ⇒ Object



139
140
141
142
143
144
145
146
147
# File 'lib/lita/handlers/bamboo.rb', line 139

def cmd_list_project_plans(response)
  proj_id = response.matches[0][0]
  begin
    info = list_project_plan(proj_id)
    response.reply info.join "\n"
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_list_projects(response) ⇒ Object



130
131
132
133
134
135
136
137
# File 'lib/lita/handlers/bamboo.rb', line 130

def cmd_list_projects(response)
  begin
    info = list_projects
    response.reply info.join "\n"
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_list_queue(response) ⇒ Object



186
187
188
189
190
191
192
193
# File 'lib/lita/handlers/bamboo.rb', line 186

def cmd_list_queue(response)
  begin
    info = list_queue
    response.reply info
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_pause(response) ⇒ Object



244
245
246
247
248
249
250
251
# File 'lib/lita/handlers/bamboo.rb', line 244

def cmd_pause(response)
  begin
    success= pause_server
    response.reply "Server paused."
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_prepare_restart(response) ⇒ Object



262
263
264
265
266
267
268
269
# File 'lib/lita/handlers/bamboo.rb', line 262

def cmd_prepare_restart(response)
  begin
    success= prepare_restart
    response.reply "Server prepared for restart."
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_queue_plan(response) ⇒ Object



160
161
162
163
164
165
166
167
168
169
170
# File 'lib/lita/handlers/bamboo.rb', line 160

def cmd_queue_plan(response)
  plan_id = response.matches[0][0]
  begin
    success = queue_plan(plan_id)
    unless success
      response.reply "Failed to queue plan #{plan_id}"
    end
  rescue Exception => e
    response.reply e.message
  end
end

#cmd_resume(response) ⇒ Object



253
254
255
256
257
258
259
260
# File 'lib/lita/handlers/bamboo.rb', line 253

def cmd_resume(response)
  begin
    success= resume_server
    response.reply "Server resumed."
  rescue Exception => e
    response.reply e.message
  end
end