bamboo-client 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/cucumber.yml +2 -0
- data/features/rest.feature +22 -0
- data/features/step_definitions/remote_steps.rb +1 -1
- data/features/step_definitions/rest_steps.rb +33 -0
- data/features/support/env.rb +3 -1
- data/lib/bamboo-client.rb +2 -0
- data/lib/bamboo-client/http/abstract.rb +23 -0
- data/lib/bamboo-client/http/json.rb +44 -0
- data/lib/bamboo-client/http/xml.rb +0 -8
- data/lib/bamboo-client/rest.rb +161 -0
- data/lib/bamboo-client/version.rb +1 -1
- data/spec/bamboo-client/http/json_spec.rb +80 -0
- data/spec/bamboo-client/http/xml_spec.rb +7 -2
- data/spec/bamboo-client/rest_spec.rb +143 -3
- data/spec/fixtures/build.json +12 -0
- data/spec/fixtures/build_with_changes.json +76 -0
- data/spec/fixtures/change.json +20 -0
- data/spec/fixtures/plan.json +12 -0
- data/spec/fixtures/project.json +8 -0
- data/spec/spec_helper.rb +6 -0
- metadata +20 -24
data/cucumber.yml
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: Bamboo REST client
|
2
|
+
In order to know more about our build pipeline
|
3
|
+
As a Bamboo user
|
4
|
+
I want to use Bamboo's REST API
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am using the REST client
|
8
|
+
|
9
|
+
Scenario: Fetch plans
|
10
|
+
When I fetch all the plans
|
11
|
+
Then I should get a list of plans
|
12
|
+
And all plans should have a key
|
13
|
+
|
14
|
+
Scenario: Fetch projects
|
15
|
+
When I fetch all projects
|
16
|
+
Then I should get a list of projects
|
17
|
+
And all projects should have a key
|
18
|
+
|
19
|
+
Scenario: Fetch all builds
|
20
|
+
When I fetch all builds
|
21
|
+
Then I should get a list of builds
|
22
|
+
And all builds should have a state
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
|
13
13
|
Then /^I should get a list of builds$/ do
|
14
14
|
@builds.should_not be_empty
|
15
|
-
@builds.each { |e| e.should be_kind_of(
|
15
|
+
@builds.each { |e| e.should be_kind_of(client.class::Build) }
|
16
16
|
end
|
17
17
|
|
18
18
|
When /^I fetch a build result$/ do
|
@@ -0,0 +1,33 @@
|
|
1
|
+
When /^I fetch all the plans$/ do
|
2
|
+
@plans = client.plans
|
3
|
+
end
|
4
|
+
|
5
|
+
Then /^I should get a list of plans$/ do
|
6
|
+
@plans.should_not be_empty
|
7
|
+
@plans.each { |plan| plan.should be_kind_of(Bamboo::Client::Rest::Plan) }
|
8
|
+
end
|
9
|
+
|
10
|
+
When /^I fetch all projects$/ do
|
11
|
+
@projects = client.projects
|
12
|
+
end
|
13
|
+
|
14
|
+
Then /^I should get a list of projects$/ do
|
15
|
+
@projects.should_not be_empty
|
16
|
+
@projects.each { |pro| pro.should be_kind_of(Bamboo::Client::Rest::Project) }
|
17
|
+
end
|
18
|
+
|
19
|
+
Then /^all plans should have a key$/ do
|
20
|
+
@plans.each { |e| e.key.should be_kind_of(String) }
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^all projects should have a key$/ do
|
24
|
+
@projects.each { |e| e.key.should be_kind_of(String) }
|
25
|
+
end
|
26
|
+
|
27
|
+
When /^I fetch all builds$/ do
|
28
|
+
@builds = client.builds
|
29
|
+
end
|
30
|
+
|
31
|
+
Then /^all builds should have a state$/ do
|
32
|
+
@builds.each { |b| [:successful, :failed].should include(b.state) }
|
33
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
$:.unshift File.expand_path("../../../lib", __FILE__)
|
2
2
|
require "bamboo-client"
|
3
3
|
|
4
|
+
$DEBUG = false
|
5
|
+
|
4
6
|
module BambooClientHelper
|
5
7
|
attr_reader :client
|
6
8
|
|
@@ -27,4 +29,4 @@ module BambooClientHelper
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
World(BambooClientHelper)
|
32
|
+
World(BambooClientHelper)
|
data/lib/bamboo-client.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require "uri"
|
2
2
|
require "restclient"
|
3
|
+
require "time"
|
3
4
|
|
4
5
|
require "bamboo-client/version"
|
5
6
|
require "bamboo-client/http"
|
@@ -7,6 +8,7 @@ require "bamboo-client/abstract"
|
|
7
8
|
require "bamboo-client/rest"
|
8
9
|
require "bamboo-client/remote"
|
9
10
|
|
11
|
+
require "pp" if $DEBUG
|
10
12
|
|
11
13
|
module Bamboo
|
12
14
|
module Client
|
@@ -7,6 +7,29 @@ module Bamboo
|
|
7
7
|
def initialize(url)
|
8
8
|
@uri = URI.parse url
|
9
9
|
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def uri_for(uri_or_path, params = nil)
|
14
|
+
if uri_or_path.kind_of? URI
|
15
|
+
u = uri_or_path.dup
|
16
|
+
|
17
|
+
u.host = @uri.host
|
18
|
+
u.port = @uri.port
|
19
|
+
u.scheme = @uri.scheme
|
20
|
+
else
|
21
|
+
u = uri.dup
|
22
|
+
u.path = uri_or_path
|
23
|
+
end
|
24
|
+
|
25
|
+
u.query = query_string_for(params) if params
|
26
|
+
u.to_s
|
27
|
+
end
|
28
|
+
|
29
|
+
def query_string_for(params)
|
30
|
+
params.map { |k, v| "#{k.to_s}=#{CGI.escape(v.to_s)}" }.join('&')
|
31
|
+
end
|
32
|
+
|
10
33
|
end # Abstract
|
11
34
|
end # Http
|
12
35
|
end # Client
|
@@ -4,6 +4,50 @@ module Bamboo
|
|
4
4
|
module Client
|
5
5
|
module Http
|
6
6
|
class Json < Abstract
|
7
|
+
class Doc
|
8
|
+
attr_reader :data
|
9
|
+
|
10
|
+
def self.from(str)
|
11
|
+
new JSON.parse(str)
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(data)
|
15
|
+
@data = data
|
16
|
+
pp @data if $DEBUG
|
17
|
+
end
|
18
|
+
|
19
|
+
def doc_for(key)
|
20
|
+
Doc.new @data.fetch(key)
|
21
|
+
end
|
22
|
+
|
23
|
+
def auto_expand(klass, client)
|
24
|
+
key_to_expand = @data.fetch('expand')
|
25
|
+
|
26
|
+
obj = @data[key_to_expand]
|
27
|
+
case obj
|
28
|
+
when Hash
|
29
|
+
if obj.has_key?('expand')
|
30
|
+
Doc.new(obj).auto_expand(klass, client)
|
31
|
+
else
|
32
|
+
klass.new(obj, client)
|
33
|
+
end
|
34
|
+
when Array
|
35
|
+
obj.map { |e| klass.new(e, client) }
|
36
|
+
else
|
37
|
+
raise TypeError, "don't know how to auto-expand #{obj.inspect}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end # Doc
|
41
|
+
|
42
|
+
def post(uri_or_path, data = {})
|
43
|
+
resp = RestClient.post(uri_for(uri_or_path), data.to_json, :accept => :json, :content_type => :json)
|
44
|
+
Doc.from(resp) unless resp.empty?
|
45
|
+
end
|
46
|
+
|
47
|
+
def get(uri_or_path, params = nil)
|
48
|
+
uri = uri_for(uri_or_path, params)
|
49
|
+
Doc.from RestClient.get(uri, :accept => :json)
|
50
|
+
end
|
7
51
|
|
8
52
|
end # Json
|
9
53
|
end # Http
|
data/lib/bamboo-client/rest.rb
CHANGED
@@ -8,6 +8,167 @@ module Bamboo
|
|
8
8
|
#
|
9
9
|
|
10
10
|
class Rest < Abstract
|
11
|
+
def initialize(http)
|
12
|
+
super
|
13
|
+
@service = "/rest/api/latest"
|
14
|
+
end
|
15
|
+
|
16
|
+
def plans
|
17
|
+
get("plan/").auto_expand Plan, @http
|
18
|
+
end
|
19
|
+
|
20
|
+
def projects
|
21
|
+
get("project/").auto_expand Project, @http
|
22
|
+
end
|
23
|
+
|
24
|
+
def builds
|
25
|
+
get("build/").auto_expand Build, @http
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def get(what)
|
31
|
+
@http.get File.join(@service, what)
|
32
|
+
end
|
33
|
+
|
34
|
+
class Plan
|
35
|
+
def initialize(data, http)
|
36
|
+
@data = data
|
37
|
+
@http = http
|
38
|
+
end
|
39
|
+
|
40
|
+
def enabled?
|
41
|
+
@data['enabled']
|
42
|
+
end
|
43
|
+
|
44
|
+
def type
|
45
|
+
@data['type'].downcase.to_sym
|
46
|
+
end
|
47
|
+
|
48
|
+
def name
|
49
|
+
@data['name']
|
50
|
+
end
|
51
|
+
|
52
|
+
def key
|
53
|
+
@data['key']
|
54
|
+
end
|
55
|
+
|
56
|
+
def url
|
57
|
+
@data.fetch("link")['href']
|
58
|
+
end
|
59
|
+
end # Plan
|
60
|
+
|
61
|
+
class Project
|
62
|
+
def initialize(data, http)
|
63
|
+
@data = data
|
64
|
+
@http = http
|
65
|
+
end
|
66
|
+
|
67
|
+
def name
|
68
|
+
@data['name']
|
69
|
+
end
|
70
|
+
|
71
|
+
def key
|
72
|
+
@data['key']
|
73
|
+
end
|
74
|
+
|
75
|
+
def url
|
76
|
+
@data.fetch("link")['href']
|
77
|
+
end
|
78
|
+
end # Project
|
79
|
+
|
80
|
+
class Build
|
81
|
+
def initialize(data, http)
|
82
|
+
@data = data
|
83
|
+
@http = http
|
84
|
+
|
85
|
+
@changes = nil
|
86
|
+
end
|
87
|
+
|
88
|
+
def state
|
89
|
+
@data.fetch('state').downcase.to_sym
|
90
|
+
end
|
91
|
+
|
92
|
+
def life_cycle_state
|
93
|
+
@data.fetch("lifeCycleState").downcase.to_sym
|
94
|
+
end
|
95
|
+
|
96
|
+
def number
|
97
|
+
@data['number']
|
98
|
+
end
|
99
|
+
|
100
|
+
def key
|
101
|
+
@data['key']
|
102
|
+
end
|
103
|
+
|
104
|
+
def id
|
105
|
+
@data['id']
|
106
|
+
end
|
107
|
+
|
108
|
+
def url
|
109
|
+
@data.fetch("link")['href']
|
110
|
+
end
|
111
|
+
|
112
|
+
def uri
|
113
|
+
@uri ||= URI.parse(url)
|
114
|
+
end
|
115
|
+
|
116
|
+
def changes
|
117
|
+
@changes ||= (
|
118
|
+
doc = fetch_details("changes.change.files").doc_for('changes')
|
119
|
+
doc.auto_expand Change, @http
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
private
|
124
|
+
|
125
|
+
def fetch_details(expand)
|
126
|
+
@http.get(uri, :expand => expand)
|
127
|
+
end
|
128
|
+
end # Build
|
129
|
+
|
130
|
+
class Change
|
131
|
+
def initialize(data, http)
|
132
|
+
@data = data
|
133
|
+
@http = http
|
134
|
+
end
|
135
|
+
|
136
|
+
def id
|
137
|
+
@data['changesetId']
|
138
|
+
end
|
139
|
+
|
140
|
+
def date
|
141
|
+
Time.parse @data['date']
|
142
|
+
end
|
143
|
+
|
144
|
+
def author
|
145
|
+
@data['author']
|
146
|
+
end
|
147
|
+
|
148
|
+
def full_name
|
149
|
+
@data['fullName']
|
150
|
+
end
|
151
|
+
|
152
|
+
def user_name
|
153
|
+
@data['userName']
|
154
|
+
end
|
155
|
+
|
156
|
+
def comment
|
157
|
+
@data['comment']
|
158
|
+
end
|
159
|
+
|
160
|
+
def files
|
161
|
+
# could use expand here
|
162
|
+
Array(@data.fetch('files')['file']).map do |data|
|
163
|
+
{
|
164
|
+
:name => data['name'],
|
165
|
+
:revision => data['revision']
|
166
|
+
}
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
|
171
|
+
end # Change
|
11
172
|
|
12
173
|
end # Rest
|
13
174
|
end # Client
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require File.expand_path("../../../spec_helper", __FILE__)
|
2
|
+
|
3
|
+
module Bamboo
|
4
|
+
module Client
|
5
|
+
module Http
|
6
|
+
describe Json do
|
7
|
+
let(:url) { "http://example.com" }
|
8
|
+
let(:json) { Json.new(url) }
|
9
|
+
|
10
|
+
it "does a GET" do
|
11
|
+
RestClient.should_receive(:get).with(
|
12
|
+
"#{url}/", :accept => :json
|
13
|
+
).and_return('{"some": "data"}')
|
14
|
+
|
15
|
+
doc = json.get "/"
|
16
|
+
doc.should be_kind_of(Json::Doc)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does a POST" do
|
20
|
+
RestClient.should_receive(:post).with(
|
21
|
+
"#{url}/", '{"some":"data"}', :accept => :json, :content_type => :json
|
22
|
+
).and_return('')
|
23
|
+
|
24
|
+
json.post("/", :some => "data").should be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe Json::Doc do
|
29
|
+
it "auto expands a one-level expansion" do
|
30
|
+
doc = Json::Doc.new(
|
31
|
+
"expand" => "a",
|
32
|
+
"a" => {"some" => "data"}
|
33
|
+
)
|
34
|
+
|
35
|
+
doc.auto_expand(SpecHelper::Wrapper, nil).obj.should == {"some" => "data"}
|
36
|
+
end
|
37
|
+
|
38
|
+
it "auto expands Arrays" do
|
39
|
+
expected = [{"some" => "data"}, {"something" => "else"}]
|
40
|
+
|
41
|
+
doc = Json::Doc.new(
|
42
|
+
"expand" => "a",
|
43
|
+
"a" => expected
|
44
|
+
)
|
45
|
+
|
46
|
+
actual = doc.auto_expand(SpecHelper::Wrapper, nil).map { |e| e.obj }
|
47
|
+
actual.should == expected
|
48
|
+
end
|
49
|
+
|
50
|
+
it "auto-expands the next expansion level" do
|
51
|
+
doc = Json::Doc.new(
|
52
|
+
"expand" => "a",
|
53
|
+
"a" => {
|
54
|
+
"expand" => "b",
|
55
|
+
"b" => %w[foo bar]
|
56
|
+
}
|
57
|
+
)
|
58
|
+
|
59
|
+
actual = doc.auto_expand(SpecHelper::Wrapper, nil).map { |e| e.obj }
|
60
|
+
actual.should == %w[foo bar]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "raises a TypeError if an object can't be expanded" do
|
64
|
+
doc = Json::Doc.new(
|
65
|
+
"expand" => "a",
|
66
|
+
"a" => 1
|
67
|
+
)
|
68
|
+
|
69
|
+
lambda { doc.auto_expand(SpecHelper::Wrapper, nil) }.should raise_error(TypeError)
|
70
|
+
end
|
71
|
+
|
72
|
+
it "returns a doc for the given key" do
|
73
|
+
doc = Json::Doc.new("foo" => {"bar" => "baz"})
|
74
|
+
doc.doc_for("foo").data.should == {"bar" => "baz"}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
end # Http
|
79
|
+
end # Client
|
80
|
+
end # Bamboo
|
@@ -19,8 +19,8 @@ module Bamboo
|
|
19
19
|
end
|
20
20
|
|
21
21
|
describe Xml::Doc do
|
22
|
-
let(:wrapped) {
|
23
|
-
m = mock("nokogiri document")
|
22
|
+
let(:wrapped) {
|
23
|
+
m = mock("nokogiri document")
|
24
24
|
m.stub!(:css).with("errors error").and_return []
|
25
25
|
m
|
26
26
|
}
|
@@ -34,6 +34,11 @@ module Bamboo
|
|
34
34
|
doc.text_for("some selector").should == "bar"
|
35
35
|
end
|
36
36
|
|
37
|
+
it "checks for errors in the given document" do
|
38
|
+
wrapped.should_receive(:css).with("errors error").and_return [mock(:text => "error!")]
|
39
|
+
lambda { doc.text_for "some selector" }.should raise_error(Bamboo::Client::Error)
|
40
|
+
end
|
41
|
+
|
37
42
|
it "returns an instance of the given class for each node matching the selector" do
|
38
43
|
wrapped.should_receive(:css).with("selector").and_return(['node1', 'node2'])
|
39
44
|
|
@@ -4,8 +4,148 @@ module Bamboo
|
|
4
4
|
module Client
|
5
5
|
describe Rest do
|
6
6
|
let(:http) { mock(Http::Json) }
|
7
|
+
let(:document) { mock(Http::Json::Doc) }
|
7
8
|
let(:client) { Rest.new(http) }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
10
|
+
it "should be able to fetch plans" do
|
11
|
+
document.should_receive(:auto_expand).with(Rest::Plan, http).and_return %w[foo bar]
|
12
|
+
|
13
|
+
http.should_receive(:get).with(
|
14
|
+
"/rest/api/latest/plan/"
|
15
|
+
).and_return(document)
|
16
|
+
|
17
|
+
client.plans.should == %w[foo bar]
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should be able to fetch projects" do
|
21
|
+
document.should_receive(:auto_expand).with(Rest::Project, http).and_return %w[foo bar]
|
22
|
+
|
23
|
+
http.should_receive(:get).with("/rest/api/latest/project/").
|
24
|
+
and_return(document)
|
25
|
+
|
26
|
+
client.projects.should == %w[foo bar]
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should be able to fetch builds" do
|
30
|
+
document.should_receive(:auto_expand).with(Rest::Build, http).and_return %w[foo bar]
|
31
|
+
|
32
|
+
http.should_receive(:get).with("/rest/api/latest/build/").
|
33
|
+
and_return(document)
|
34
|
+
|
35
|
+
client.builds.should == %w[foo bar]
|
36
|
+
end
|
37
|
+
|
38
|
+
describe Rest::Plan do
|
39
|
+
let(:data) { json_fixture("plan") }
|
40
|
+
let(:plan) { Rest::Plan.new data, http }
|
41
|
+
|
42
|
+
it "knows if the plan is enabled" do
|
43
|
+
plan.should be_enabled
|
44
|
+
end
|
45
|
+
|
46
|
+
it "has a type" do
|
47
|
+
plan.type.should == :chain
|
48
|
+
end
|
49
|
+
|
50
|
+
it "has a name" do
|
51
|
+
plan.name.should == "Selenium 2 Ruby - WebDriver Remote Client Tests - Windows"
|
52
|
+
end
|
53
|
+
|
54
|
+
it "has a key" do
|
55
|
+
plan.key.should == "S2RB-REMWIN"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "has a URL" do
|
59
|
+
plan.url.should == "http://xserve.openqa.org:8085/rest/api/latest/plan/S2RB-REMWIN"
|
60
|
+
end
|
61
|
+
end # Plan
|
62
|
+
|
63
|
+
describe Rest::Project do
|
64
|
+
let(:data) { json_fixture("project") }
|
65
|
+
let(:plan) { Rest::Project.new data, http }
|
66
|
+
|
67
|
+
it "has a name" do
|
68
|
+
plan.name.should == "Selenium 2 Java"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "has a key" do
|
72
|
+
plan.key.should == "S2J"
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has a URL" do
|
76
|
+
plan.url.should == "http://xserve.openqa.org:8085/rest/api/latest/project/S2J"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe Rest::Build do
|
81
|
+
let(:data) { json_fixture("build") }
|
82
|
+
let(:build) { Rest::Build.new data, http }
|
83
|
+
|
84
|
+
it "has a key" do
|
85
|
+
build.key.should == "IAD-DEFAULT-5388"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "has a state" do
|
89
|
+
build.state.should == :successful
|
90
|
+
end
|
91
|
+
|
92
|
+
it "has an id" do
|
93
|
+
build.id.should == 8487295
|
94
|
+
end
|
95
|
+
|
96
|
+
it "has a number" do
|
97
|
+
build.number.should == 5388
|
98
|
+
end
|
99
|
+
|
100
|
+
it "has a life cycle state" do
|
101
|
+
build.life_cycle_state.should == :finished
|
102
|
+
end
|
103
|
+
|
104
|
+
it "has a URL" do
|
105
|
+
build.url.should == "http://localhost:8085/rest/api/latest/result/IAD-DEFAULT-5388"
|
106
|
+
end
|
107
|
+
|
108
|
+
it "has a list of changes" do
|
109
|
+
# TODO: arg expectation
|
110
|
+
http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("build_with_changes"))
|
111
|
+
build.changes.first.should be_kind_of(Rest::Change)
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
describe Rest::Change do
|
116
|
+
let(:data) { json_fixture("change") }
|
117
|
+
let(:change) { Rest::Change.new data, http }
|
118
|
+
|
119
|
+
it "has an id" do
|
120
|
+
change.id.should == "131"
|
121
|
+
end
|
122
|
+
|
123
|
+
it "has a date" do
|
124
|
+
change.date.should == Time.parse("2011-01-20T10:04:47.000+01:00")
|
125
|
+
end
|
126
|
+
|
127
|
+
it "has an author" do
|
128
|
+
change.author.should == "joedev"
|
129
|
+
end
|
130
|
+
|
131
|
+
it "has a full name" do
|
132
|
+
change.full_name.should == "Joe Developer"
|
133
|
+
end
|
134
|
+
|
135
|
+
it "has a username" do
|
136
|
+
change.user_name.should == "joedev"
|
137
|
+
end
|
138
|
+
|
139
|
+
it "has a comment" do
|
140
|
+
change.comment.should == "Fixed the config thing."
|
141
|
+
end
|
142
|
+
|
143
|
+
it "has a list of files" do
|
144
|
+
change.files.first.should == {:name => "/trunk/server/src/main/resources/some-config.ini", :revision => "131"}
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
|
149
|
+
end # Rest
|
150
|
+
end # Client
|
151
|
+
end # Bamboo
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"type": "restChainResult",
|
3
|
+
"id": 8487295,
|
4
|
+
"number": 5388,
|
5
|
+
"lifeCycleState": "Finished",
|
6
|
+
"state": "Successful",
|
7
|
+
"key": "IAD-DEFAULT-5388",
|
8
|
+
"link": {
|
9
|
+
"rel": "self",
|
10
|
+
"href": "http://localhost:8085/rest/api/latest/result/IAD-DEFAULT-5388"
|
11
|
+
}
|
12
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
{
|
2
|
+
"id": 8159340,
|
3
|
+
"number": 29,
|
4
|
+
"lifeCycleState": "Finished",
|
5
|
+
"state": "Successful",
|
6
|
+
"key": "ADS-DEFAULT-29",
|
7
|
+
"expand": "changes,metadata,stages,labels,jiraIssues,comments",
|
8
|
+
"link": {
|
9
|
+
"rel": "self",
|
10
|
+
"href": "http://localhost:8085/rest/api/latest/build/ADS-DEFAULT-29"
|
11
|
+
},
|
12
|
+
"buildStartedTime": "2011-01-20T10:08:41.000+01:00",
|
13
|
+
"buildCompletedTime": "2011-01-20T10:09:32.000+01:00",
|
14
|
+
"buildDurationInSeconds": 51,
|
15
|
+
"buildDuration": 51074,
|
16
|
+
"buildDurationDescription": "51 seconds",
|
17
|
+
"buildRelativeTime": "4 weeks ago",
|
18
|
+
"vcsRevisionKey": "131",
|
19
|
+
"buildTestSummary": "13 passed",
|
20
|
+
"successfulTestCount": 13,
|
21
|
+
"failedTestCount": 0,
|
22
|
+
"buildReason": "Code has changed",
|
23
|
+
"stages": {
|
24
|
+
"size": 1,
|
25
|
+
"max-result": 1,
|
26
|
+
"start-index": 0
|
27
|
+
},
|
28
|
+
"labels": {
|
29
|
+
"size": 0,
|
30
|
+
"max-result": 0,
|
31
|
+
"start-index": 0
|
32
|
+
},
|
33
|
+
"jiraIssues": {
|
34
|
+
"size": 1,
|
35
|
+
"max-result": 1,
|
36
|
+
"start-index": 0
|
37
|
+
},
|
38
|
+
"comments": {
|
39
|
+
"size": 0,
|
40
|
+
"max-result": 0,
|
41
|
+
"start-index": 0
|
42
|
+
},
|
43
|
+
"changes": {
|
44
|
+
"expand": "change",
|
45
|
+
"size": 1,
|
46
|
+
"max-result": 1,
|
47
|
+
"start-index": 0,
|
48
|
+
"change": [
|
49
|
+
{
|
50
|
+
"changesetId": "131",
|
51
|
+
"fullName": "Joe Developer",
|
52
|
+
"userName": "joedev",
|
53
|
+
"author": "joedev",
|
54
|
+
"expand": "files",
|
55
|
+
"comment": "Fixed the config thing.",
|
56
|
+
"date": "2011-01-20T10:04:47.000+01:00",
|
57
|
+
"files": {
|
58
|
+
"size": 1,
|
59
|
+
"max-result": 1,
|
60
|
+
"start-index": 0,
|
61
|
+
"file": [
|
62
|
+
{
|
63
|
+
"name": "/trunk/server/src/main/resources/some-config.ini",
|
64
|
+
"revision": "131"
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
68
|
+
}
|
69
|
+
]
|
70
|
+
},
|
71
|
+
"metadata": {
|
72
|
+
"size": 7,
|
73
|
+
"max-result": 7,
|
74
|
+
"start-index": 0
|
75
|
+
}
|
76
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"changesetId": "131",
|
3
|
+
"fullName": "Joe Developer",
|
4
|
+
"userName": "joedev",
|
5
|
+
"author": "joedev",
|
6
|
+
"expand": "files",
|
7
|
+
"comment": "Fixed the config thing.",
|
8
|
+
"date": "2011-01-20T10:04:47.000+01:00",
|
9
|
+
"files": {
|
10
|
+
"size": 1,
|
11
|
+
"max-result": 1,
|
12
|
+
"start-index": 0,
|
13
|
+
"file": [
|
14
|
+
{
|
15
|
+
"name": "/trunk/server/src/main/resources/some-config.ini",
|
16
|
+
"revision": "131"
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
}
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,12 @@ module Bamboo::Client::SpecHelper
|
|
16
16
|
Nokogiri.XML File.read(path)
|
17
17
|
end
|
18
18
|
|
19
|
+
def json_fixture(name)
|
20
|
+
path = File.join fixture_path("#{name}.json")
|
21
|
+
|
22
|
+
JSON.parse File.read(path)
|
23
|
+
end
|
24
|
+
|
19
25
|
def fixture_path(file)
|
20
26
|
dir = File.expand_path("../fixtures", __FILE__)
|
21
27
|
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bamboo-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
version: 0.0.3
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Jari Bakken
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date: 2011-
|
13
|
+
date: 2011-02-17 00:00:00 +01:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :development
|
32
26
|
version_requirements: *id001
|
@@ -38,8 +32,6 @@ dependencies:
|
|
38
32
|
requirements:
|
39
33
|
- - ">="
|
40
34
|
- !ruby/object:Gem::Version
|
41
|
-
segments:
|
42
|
-
- 0
|
43
35
|
version: "0"
|
44
36
|
type: :development
|
45
37
|
version_requirements: *id002
|
@@ -51,8 +43,6 @@ dependencies:
|
|
51
43
|
requirements:
|
52
44
|
- - ">="
|
53
45
|
- !ruby/object:Gem::Version
|
54
|
-
segments:
|
55
|
-
- 0
|
56
46
|
version: "0"
|
57
47
|
type: :development
|
58
48
|
version_requirements: *id003
|
@@ -64,8 +54,6 @@ dependencies:
|
|
64
54
|
requirements:
|
65
55
|
- - ">="
|
66
56
|
- !ruby/object:Gem::Version
|
67
|
-
segments:
|
68
|
-
- 0
|
69
57
|
version: "0"
|
70
58
|
type: :runtime
|
71
59
|
version_requirements: *id004
|
@@ -77,8 +65,6 @@ dependencies:
|
|
77
65
|
requirements:
|
78
66
|
- - ">="
|
79
67
|
- !ruby/object:Gem::Version
|
80
|
-
segments:
|
81
|
-
- 0
|
82
68
|
version: "0"
|
83
69
|
type: :runtime
|
84
70
|
version_requirements: *id005
|
@@ -90,8 +76,6 @@ dependencies:
|
|
90
76
|
requirements:
|
91
77
|
- - ">="
|
92
78
|
- !ruby/object:Gem::Version
|
93
|
-
segments:
|
94
|
-
- 0
|
95
79
|
version: "0"
|
96
80
|
type: :runtime
|
97
81
|
version_requirements: *id006
|
@@ -114,7 +98,9 @@ files:
|
|
114
98
|
- bamboo-client.gemspec
|
115
99
|
- cucumber.yml
|
116
100
|
- features/remote.feature
|
101
|
+
- features/rest.feature
|
117
102
|
- features/step_definitions/remote_steps.rb
|
103
|
+
- features/step_definitions/rest_steps.rb
|
118
104
|
- features/support/env.rb
|
119
105
|
- lib/bamboo-client.rb
|
120
106
|
- lib/bamboo-client/abstract.rb
|
@@ -126,11 +112,17 @@ files:
|
|
126
112
|
- lib/bamboo-client/rest.rb
|
127
113
|
- lib/bamboo-client/version.rb
|
128
114
|
- spec/bamboo-client/client_spec.rb
|
115
|
+
- spec/bamboo-client/http/json_spec.rb
|
129
116
|
- spec/bamboo-client/http/xml_spec.rb
|
130
117
|
- spec/bamboo-client/remote_spec.rb
|
131
118
|
- spec/bamboo-client/rest_spec.rb
|
119
|
+
- spec/fixtures/build.json
|
132
120
|
- spec/fixtures/build.xml
|
133
121
|
- spec/fixtures/build_result.xml
|
122
|
+
- spec/fixtures/build_with_changes.json
|
123
|
+
- spec/fixtures/change.json
|
124
|
+
- spec/fixtures/plan.json
|
125
|
+
- spec/fixtures/project.json
|
134
126
|
- spec/spec_helper.rb
|
135
127
|
has_rdoc: true
|
136
128
|
homepage: ""
|
@@ -146,32 +138,36 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
146
138
|
requirements:
|
147
139
|
- - ">="
|
148
140
|
- !ruby/object:Gem::Version
|
149
|
-
segments:
|
150
|
-
- 0
|
151
141
|
version: "0"
|
152
142
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
143
|
none: false
|
154
144
|
requirements:
|
155
145
|
- - ">="
|
156
146
|
- !ruby/object:Gem::Version
|
157
|
-
segments:
|
158
|
-
- 0
|
159
147
|
version: "0"
|
160
148
|
requirements: []
|
161
149
|
|
162
150
|
rubyforge_project: bamboo-client
|
163
|
-
rubygems_version: 1.
|
151
|
+
rubygems_version: 1.5.2
|
164
152
|
signing_key:
|
165
153
|
specification_version: 3
|
166
154
|
summary: Ruby client for Atlassian Bamboo's REST APIs
|
167
155
|
test_files:
|
168
156
|
- features/remote.feature
|
157
|
+
- features/rest.feature
|
169
158
|
- features/step_definitions/remote_steps.rb
|
159
|
+
- features/step_definitions/rest_steps.rb
|
170
160
|
- features/support/env.rb
|
171
161
|
- spec/bamboo-client/client_spec.rb
|
162
|
+
- spec/bamboo-client/http/json_spec.rb
|
172
163
|
- spec/bamboo-client/http/xml_spec.rb
|
173
164
|
- spec/bamboo-client/remote_spec.rb
|
174
165
|
- spec/bamboo-client/rest_spec.rb
|
166
|
+
- spec/fixtures/build.json
|
175
167
|
- spec/fixtures/build.xml
|
176
168
|
- spec/fixtures/build_result.xml
|
169
|
+
- spec/fixtures/build_with_changes.json
|
170
|
+
- spec/fixtures/change.json
|
171
|
+
- spec/fixtures/plan.json
|
172
|
+
- spec/fixtures/project.json
|
177
173
|
- spec/spec_helper.rb
|