lita-bamboo 0.1.0
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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/Gemfile +3 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/lib/bamboohelper/misc.rb +8 -0
- data/lib/bamboohelper/plans.rb +97 -0
- data/lib/lita/handlers/bamboo.rb +73 -0
- data/lib/lita-bamboo.rb +15 -0
- data/lita-bamboo.gemspec +24 -0
- data/locales/en.yml +11 -0
- data/spec/lita/handlers/bamboo_spec.rb +49 -0
- data/spec/spec_helper.rb +14 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bb8c8f699d19940de58574cf3675e8b5cd5fe0a9
|
4
|
+
data.tar.gz: 1602cfba0a6d5c5f0723d12c334ed0eba41d0cda
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 039b34362887b450baef8a95b1106d80f105ac4e86335cf8d7d3ad98aee86d53fcf192098a887b65148fd0f6c65fcfc34dc88e42f480a33d4ce189b168b5ac28
|
7
|
+
data.tar.gz: 48d9683aa3241251278d3b08147aac2f632faefc1a9e4ea62ca2edf57cf09e5ef1af2e8c3f83b54366ff710ee42eb27e3a5eb8548ebe794f2819d185777ba9e5
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# lita-bamboo
|
2
|
+
|
3
|
+
TODO: Add a description of the plugin.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-bamboo to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-bamboo"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
TODO: Describe any configuration attributes the plugin exposes.
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
TODO: Describe the plugin's features and how to use them.
|
data/Rakefile
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'json'
|
2
|
+
module LitaBambooHelper
|
3
|
+
module Plan
|
4
|
+
def list_projects
|
5
|
+
url = "#{config.url}/project.json"
|
6
|
+
info = []
|
7
|
+
begin
|
8
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
|
9
|
+
json_response = JSON.parse(response)
|
10
|
+
if json_response['projects']['project']
|
11
|
+
json_response['projects']['project'].each do |proj|
|
12
|
+
info << "[#{proj['key']}] : #{proj['name']}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
rescue Exception=>e
|
16
|
+
raise "Error to list projects :#{e.message}"
|
17
|
+
end
|
18
|
+
info
|
19
|
+
end
|
20
|
+
|
21
|
+
def list_project_plan(proj_id)
|
22
|
+
url = "#{config.url}/project/#{proj_id}.json?expand=plans"
|
23
|
+
info = []
|
24
|
+
begin
|
25
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
|
26
|
+
json_response = JSON.parse(response)
|
27
|
+
if json_response['plans']['plan']
|
28
|
+
json_response['plans']['plan'].each do |plan|
|
29
|
+
info << "[#{plan['key']}] : #{plan['name']}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
rescue Exception=>e
|
33
|
+
raise "Error to list plans :#{e.message}"
|
34
|
+
end
|
35
|
+
info
|
36
|
+
end
|
37
|
+
|
38
|
+
def list_plan_build(plan_id, last=1)
|
39
|
+
count =last -1
|
40
|
+
if count<0
|
41
|
+
count=0
|
42
|
+
end
|
43
|
+
puts "***#{count}"
|
44
|
+
url = "#{config.url}/result/#{plan_id}.json?expand=results[0:#{count}].result.labels"
|
45
|
+
info = []
|
46
|
+
begin
|
47
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
|
48
|
+
json_response = JSON.parse(response)
|
49
|
+
if json_response['results']['result']
|
50
|
+
json_response['results']['result'].each do |result|
|
51
|
+
labels = []
|
52
|
+
if result['labels']['label']
|
53
|
+
result['labels']['label'].each do |label|
|
54
|
+
labels << label['name']
|
55
|
+
end
|
56
|
+
end
|
57
|
+
info << "[#{result['buildResultKey']}] : Successful=#{result['successful'] ? 'T' : 'F'} Finished=#{result['finished'] ? 'T' : 'F'} NotRunYet=#{result['notRunYet'] ? 'T' : 'F'} Start: #{result['prettyBuildStartedTime']} Complete: #{result['prettyBuildCompletedTime']} Label: #{labels.to_s}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
rescue Exception=>e
|
61
|
+
raise "Error to list build results :#{e.message}"
|
62
|
+
end
|
63
|
+
info
|
64
|
+
end
|
65
|
+
|
66
|
+
def queue_plan(plan_id)
|
67
|
+
url = "#{config.url}/queue/#{plan_id}"
|
68
|
+
begin
|
69
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :post)
|
70
|
+
if response.code == 200
|
71
|
+
true
|
72
|
+
else
|
73
|
+
false
|
74
|
+
end
|
75
|
+
rescue Exception=>e
|
76
|
+
raise "Error to queue paln for build :#{e.message}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def list_queue()
|
81
|
+
url = "#{config.url}/queue?os_authType=basic"
|
82
|
+
info = []
|
83
|
+
begin
|
84
|
+
response = RestClient::Request.execute(:url => url, :verify_ssl => config.verify_ssl, :method=> :get)
|
85
|
+
json_response = JSON.parse(response)
|
86
|
+
if json_response['results']['result']
|
87
|
+
json_response['results']['result'].each do |result|
|
88
|
+
info << "[#{result['buildResultKey']}] : Successful=#{result['successful']} Finished=#{result['finished']} NotRunYet=#{result['notRunYet']} Start: #{result['prettyBuildStartedTime']} Complete: #{result['prettyBuildCompletedTime']}"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
rescue Exception=>e
|
92
|
+
raise "Error to list build results :#{e.message}"
|
93
|
+
end
|
94
|
+
info
|
95
|
+
end
|
96
|
+
end #module
|
97
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Lita
|
2
|
+
module Handlers
|
3
|
+
class Bamboo < Handler
|
4
|
+
|
5
|
+
namespace 'Bamboo'
|
6
|
+
config :url, required: true, type: String # https://host:port/rest/api/latest
|
7
|
+
config :verify_ssl, required: true, types: [TrueClass, FalseClass], default: false
|
8
|
+
|
9
|
+
include ::LitaBambooHelper::Misc
|
10
|
+
include ::LitaBambooHelper::Plan
|
11
|
+
|
12
|
+
route(
|
13
|
+
/^bamboo\s+list\s+project[s]?\s*$/,
|
14
|
+
:cmd_list_projects,
|
15
|
+
command: true,
|
16
|
+
help: {
|
17
|
+
t('help.cmd_list_projects_key') => t('help.cmd_list_projects_value')
|
18
|
+
}
|
19
|
+
)
|
20
|
+
|
21
|
+
route(
|
22
|
+
/^bamboo\s+list\s+project\s+(\S+)\s+plans$/,
|
23
|
+
:cmd_list_project_plans,
|
24
|
+
command: true,
|
25
|
+
help: {
|
26
|
+
t('help.cmd_list_project_plans_key') => t('help.cmd_list_project_plans_value')
|
27
|
+
}
|
28
|
+
)
|
29
|
+
|
30
|
+
route(
|
31
|
+
/^bamboo\s+list\s+plan\s+(\S+)\s+results\s+limit\s+(\d+)\s*$/,
|
32
|
+
:cmd_list_plan_results,
|
33
|
+
command: true,
|
34
|
+
help: {
|
35
|
+
t('help.cmd_list_plan_results_key') => t('help.cmd_list_plan_results_value')
|
36
|
+
}
|
37
|
+
)
|
38
|
+
|
39
|
+
def cmd_list_projects(response)
|
40
|
+
begin
|
41
|
+
info = list_projects
|
42
|
+
response.reply info.join "\n"
|
43
|
+
rescue Exception => e
|
44
|
+
response.reply e.message
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def cmd_list_project_plans(response)
|
49
|
+
proj_id = response.matches[0][0]
|
50
|
+
begin
|
51
|
+
info = list_project_plan(proj_id)
|
52
|
+
response.reply info.join "\n"
|
53
|
+
rescue Exception => e
|
54
|
+
response.reply e.message
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def cmd_list_plan_results(response)
|
59
|
+
plan_id = response.matches[0][0]
|
60
|
+
limit = response.matches[0][1]
|
61
|
+
begin
|
62
|
+
info = list_plan_build(plan_id, Integer(limit))
|
63
|
+
response.reply info.join "\n"
|
64
|
+
rescue Exception => e
|
65
|
+
response.reply e.message
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
Lita.register_handler(self)
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/lib/lita-bamboo.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
Lita.load_locales Dir[File.expand_path(
|
4
|
+
File.join("..", "..", "locales", "*.yml"), __FILE__
|
5
|
+
)]
|
6
|
+
|
7
|
+
require "bamboohelper/misc"
|
8
|
+
require "bamboohelper/plans"
|
9
|
+
require "lita/handlers/bamboo"
|
10
|
+
require "lita"
|
11
|
+
|
12
|
+
Lita::Handlers::Bamboo.template_root File.expand_path(
|
13
|
+
File.join("..", "..", "templates"),
|
14
|
+
__FILE__
|
15
|
+
)
|
data/lita-bamboo.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-bamboo"
|
3
|
+
spec.version = "0.1.0"
|
4
|
+
spec.authors = ["Wang, Dawei"]
|
5
|
+
spec.email = ["dwang@entertainment.com"]
|
6
|
+
spec.description = "Bamboo Lita tasks"
|
7
|
+
spec.summary = "Bamboo build server operations"
|
8
|
+
spec.homepage = "https://github.com/af6140/lita-bamboo"
|
9
|
+
spec.license = "Apache-2.0"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.7"
|
18
|
+
spec.add_runtime_dependency "rest-client", ">= 1.7 ", "<2.0"
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
21
|
+
spec.add_development_dependency "rack", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
24
|
+
end
|
data/locales/en.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
en:
|
2
|
+
lita:
|
3
|
+
handlers:
|
4
|
+
bamboo:
|
5
|
+
help:
|
6
|
+
cmd_list_projects_key: 'bamboo list project'
|
7
|
+
cmd_list_projects_value: 'List all build project'
|
8
|
+
cmd_list_project_plans_key: 'bamboo list project PROJ_KYE plans'
|
9
|
+
cmd_list_project_plans_value: 'List all plans in project'
|
10
|
+
cmd_list_plan_results_key: 'bamboo list plan LAN_KEY results limit LIMIT'
|
11
|
+
cmd_list_plan_results_value: 'List plan build results last LIMIT'
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Bamboo, lita_handler: true do
|
4
|
+
before do
|
5
|
+
registry.config.handlers.bamboo.url = 'https://bamboo.entertainment.com/rest/api/latest'
|
6
|
+
registry.config.handlers.bamboo.verify_ssl = false
|
7
|
+
end
|
8
|
+
it do
|
9
|
+
is_expected.to route_command('bamboo list project').to(:cmd_list_projects)
|
10
|
+
is_expected.to route_command('bamboo list project AG plans').to(:cmd_list_project_plans)
|
11
|
+
is_expected.to route_command('bamboo list plan AG-FPMWIL results limit 1').to(:cmd_list_plan_results)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#get all project list' do
|
15
|
+
#let(:robot) { Lita::Robot.new(registry) }
|
16
|
+
it 'fecth list of projects' do
|
17
|
+
send_command('bamboo list project')
|
18
|
+
puts replies.last
|
19
|
+
#expect(replies.last).to match(/repositoryPath/)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#get project plan list' do
|
24
|
+
#let(:robot) { Lita::Robot.new(registry) }
|
25
|
+
it 'fecth list of plan in project' do
|
26
|
+
send_command('bamboo list project AG plans')
|
27
|
+
puts replies.last
|
28
|
+
#expect(replies.last).to match(/repositoryPath/)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#get project plan results' do
|
33
|
+
#let(:robot) { Lita::Robot.new(registry) }
|
34
|
+
it 'fecth list of plan build results' do
|
35
|
+
send_command('bamboo list plan PM-BUILDPM results limit 2')
|
36
|
+
puts replies.last
|
37
|
+
#expect(replies.last).to match(/repositoryPath/)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#get project plan results' do
|
42
|
+
#let(:robot) { Lita::Robot.new(registry) }
|
43
|
+
it 'fecth list of plan build results' do
|
44
|
+
send_command('bamboo list plan AG-FPMWIL results limit 2')
|
45
|
+
puts replies.last
|
46
|
+
#expect(replies.last).to match(/repositoryPath/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "lita-bamboo"
|
2
|
+
require "lita/rspec"
|
3
|
+
|
4
|
+
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
5
|
+
# was generated with Lita 4, the compatibility mode should be left disabled.
|
6
|
+
Lita.version_3_compatibility_mode = false
|
7
|
+
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.before do
|
11
|
+
registry.register_handler(Lita::Handlers::Bamboo)
|
12
|
+
#registry.register_hook(:trigger_route, Lita::Extensions::KeywordArguments)
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-bamboo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Wang, Dawei
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
- - "<"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '2.0'
|
37
|
+
type: :runtime
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.7'
|
44
|
+
- - "<"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rack
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.6'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.6'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rake
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rspec
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 3.0.0
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 3.0.0
|
103
|
+
description: Bamboo Lita tasks
|
104
|
+
email:
|
105
|
+
- dwang@entertainment.com
|
106
|
+
executables: []
|
107
|
+
extensions: []
|
108
|
+
extra_rdoc_files: []
|
109
|
+
files:
|
110
|
+
- ".gitignore"
|
111
|
+
- ".rspec"
|
112
|
+
- Gemfile
|
113
|
+
- README.md
|
114
|
+
- Rakefile
|
115
|
+
- lib/bamboohelper/misc.rb
|
116
|
+
- lib/bamboohelper/plans.rb
|
117
|
+
- lib/lita-bamboo.rb
|
118
|
+
- lib/lita/handlers/bamboo.rb
|
119
|
+
- lita-bamboo.gemspec
|
120
|
+
- locales/en.yml
|
121
|
+
- spec/lita/handlers/bamboo_spec.rb
|
122
|
+
- spec/spec_helper.rb
|
123
|
+
homepage: https://github.com/af6140/lita-bamboo
|
124
|
+
licenses:
|
125
|
+
- Apache-2.0
|
126
|
+
metadata:
|
127
|
+
lita_plugin_type: handler
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.4.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Bamboo build server operations
|
148
|
+
test_files:
|
149
|
+
- spec/lita/handlers/bamboo_spec.rb
|
150
|
+
- spec/spec_helper.rb
|