bamboo_api 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/bamboo_api.gemspec +26 -0
- data/lib/bamboo_api/build.rb +98 -0
- data/lib/bamboo_api/plan.rb +93 -0
- data/lib/bamboo_api/project.rb +32 -0
- data/lib/bamboo_api/stage.rb +42 -0
- data/lib/bamboo_api/version.rb +3 -0
- data/lib/bamboo_api.rb +29 -0
- data/spec/bamboo_api/build_spec.rb +73 -0
- data/spec/bamboo_api/plan_spec.rb +36 -0
- data/spec/bamboo_api_spec.rb +4 -0
- data/spec/spec_helper.rb +26 -0
- data/spec/vcr_cassettes/plans_all.json +1 -0
- data/spec/vcr_cassettes/plans_find.json +1 -0
- metadata +150 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jorge Valdivia
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# BambooApi
|
2
|
+
|
3
|
+
This gem is a wrapper for Atlassian's Bamboo's REST API. More infomation about the API can be found [here](https://developer.atlassian.com/display/BAMBOODEV/Bamboo+REST+Resources). Using this gem gives you the ability to get information on your Bamboo projects, plans, builds, and stages (for builds only). Of most use is probably the ability to check the build status of a plan.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'bamboo_api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install bamboo_api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Initialization
|
22
|
+
|
23
|
+
BambooApi.new( {end_point: "example.atlassian.net", username: "jorge@example.com", password: "password" } )
|
24
|
+
|
25
|
+
Projects
|
26
|
+
|
27
|
+
BambooApi::Project.all
|
28
|
+
BambooApi::Project.find( "KEY" )
|
29
|
+
|
30
|
+
Plans
|
31
|
+
|
32
|
+
BambooApi::Plan.all
|
33
|
+
BambooApi::Plan.find( "PLANKEY" )
|
34
|
+
BambooApi::Plan.find( "PLANKEY" ).builds
|
35
|
+
BambooApi::Plan.find( "PLANKEY" ).building?
|
36
|
+
BambooApi::Plan.find( "PLANKEY" ).readable_status
|
37
|
+
|
38
|
+
Builds
|
39
|
+
|
40
|
+
BambooApi::Build.find( "BUILDID" )
|
41
|
+
BambooApi::Build.find_by_plan( "PLANKEY" )
|
42
|
+
BambooApi::Build.find( "BUILDID" ).stages
|
43
|
+
BambooApi::Build.find( "BUILDID" ).status
|
44
|
+
BambooApi::Build.find( "BUILDID" ).failing_stage # Return the failing stage if the status if failing
|
45
|
+
|
46
|
+
Note that there is no 'all' method for builds, as the Bamboo API requires a plan key.
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bamboo_api.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'bamboo_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "bamboo_api"
|
8
|
+
gem.version = BambooApi::VERSION
|
9
|
+
gem.authors = ["Jorge Valdivia"]
|
10
|
+
gem.email = ["jorge@valdivia.me"]
|
11
|
+
gem.description = %q{Atlassian Bamboo API Wrapper}
|
12
|
+
gem.summary = %q{A simple wrapper for Atlassian's Bamboo's REST API.}
|
13
|
+
gem.homepage = "https://github.com/jorgevaldivia/bamboo_api"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_development_dependency "rspec"
|
21
|
+
gem.add_development_dependency "multi_json"
|
22
|
+
gem.add_development_dependency "vcr"
|
23
|
+
gem.add_development_dependency "webmock"
|
24
|
+
gem.add_runtime_dependency "rest-client"
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
class BambooApi::Build
|
2
|
+
|
3
|
+
# /result/PHO-UAT
|
4
|
+
attr_reader :restartable, :once_off, :continuable, :id, :number, :life_cycle_state, :state, :key,
|
5
|
+
:link, :plan_name, :project_name, :build_started_time, :build_completed_time, :build_duration_in_seconds,
|
6
|
+
:revision, :vcs_revision_key, :build_test_summary, :successful_test_count, :failed_test_count,
|
7
|
+
:quarantined_test_count, :build_reason, :user_url, :username, :stages
|
8
|
+
|
9
|
+
def initialize restartable, once_off, continuable, id, number, life_cycle_state, state, key,
|
10
|
+
link, plan_name, project_name, build_started_time, build_completed_time, build_duration_in_seconds,
|
11
|
+
vcs_revision_key, build_test_summary, successful_test_count, failed_test_count,
|
12
|
+
quarantined_test_count, build_reason, stages
|
13
|
+
|
14
|
+
@restartable = restartable
|
15
|
+
@once_off = once_off
|
16
|
+
@continuable = continuable
|
17
|
+
@id = id
|
18
|
+
@number = number
|
19
|
+
@life_cycle_state = life_cycle_state
|
20
|
+
@state = state
|
21
|
+
@key = key
|
22
|
+
@link = link
|
23
|
+
@plan_name = plan_name
|
24
|
+
@build_started_time = build_started_time
|
25
|
+
@build_completed_time = build_completed_time
|
26
|
+
@build_duration_in_seconds = build_duration_in_seconds
|
27
|
+
@revision = @vcs_revision_key = vcs_revision_key
|
28
|
+
@build_test_summary = build_test_summary
|
29
|
+
@successful_test_count = successful_test_count
|
30
|
+
@failed_test_count = failed_test_count
|
31
|
+
@quarantined_test_count = quarantined_test_count
|
32
|
+
@build_reason = build_reason
|
33
|
+
@user_url = user_url
|
34
|
+
@username = username
|
35
|
+
@stages = stages
|
36
|
+
|
37
|
+
@user_url = parse_user_url
|
38
|
+
@username = parse_username
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse_username
|
42
|
+
self.build_reason.scan(/>(.*)</).flatten.first if !build_reason.nil? && !build_reason.empty?
|
43
|
+
end
|
44
|
+
|
45
|
+
def parse_user_url
|
46
|
+
self.build_reason.scan(/href="(.*)"/).flatten.first if !build_reason.nil? && !build_reason.empty?
|
47
|
+
end
|
48
|
+
|
49
|
+
def successful?
|
50
|
+
self.state == "Successful"
|
51
|
+
end
|
52
|
+
|
53
|
+
def failed?
|
54
|
+
self.state == "Failed"
|
55
|
+
end
|
56
|
+
|
57
|
+
def failing_stage
|
58
|
+
failing = nil
|
59
|
+
self.stages.each do | stage |
|
60
|
+
if stage.failed?
|
61
|
+
failing = stage
|
62
|
+
break
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
failing
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.parse builds
|
70
|
+
parsed_builds = []
|
71
|
+
|
72
|
+
builds[ "results" ][ "result" ].each do | build |
|
73
|
+
parsed_builds.push( BambooApi::Build.parse_single( build ) )
|
74
|
+
end
|
75
|
+
|
76
|
+
parsed_builds
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.parse_single build
|
80
|
+
stages = BambooApi::Stage.parse( build )
|
81
|
+
BambooApi::Build.new build[ "restartable" ], build[ "onceOff" ], build[ "continuable" ], build[ "id" ], build[ "number" ], build[ "lifeCycleState" ],
|
82
|
+
build[ "state" ], build[ "key" ], build[ "link" ], build[ "planName" ], build[ "projectName" ], build[ "buildStartedTime" ],
|
83
|
+
build[ "buildCompletedTime" ], build[ "buildDurationInSeconds" ], build[ "vcsRevisionKey" ], build[ "buildTestSummary" ],
|
84
|
+
build[ "successfulTestCount" ], build[ "failedTestCount" ], build[ "quarantinedTestCount" ], build[ "buildReason" ], stages
|
85
|
+
end
|
86
|
+
|
87
|
+
def self.all
|
88
|
+
raise "You must use the method find_by_plan. Sorry."
|
89
|
+
end
|
90
|
+
|
91
|
+
def self.find key
|
92
|
+
BambooApi::Build.parse_single( BambooApi.request "result/#{key}", "stages" )
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.find_by_plan plan_key
|
96
|
+
BambooApi::Build.parse( BambooApi.request "result/#{plan_key}", "results.result.stages" )
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
class BambooApi::Plan < BambooApi
|
2
|
+
|
3
|
+
attr_reader :short_name, :short_key, :type, :enabled, :link, :key, :name,
|
4
|
+
:is_favourite, :is_active, :is_building, :average_build_time, :actions, :stages, :branches,
|
5
|
+
:builds_cache
|
6
|
+
|
7
|
+
def initialize short_name, short_key, type, enabled, link, key, name, is_favourite=nil,
|
8
|
+
is_active=nil, is_building=nil, average_build_time=nil, actions=nil, stages=nil, branches=nil
|
9
|
+
|
10
|
+
@short_name = short_name
|
11
|
+
@short_key = short_key
|
12
|
+
@type = type
|
13
|
+
@enabled = enabled
|
14
|
+
@link = link
|
15
|
+
@key = key
|
16
|
+
@name = name
|
17
|
+
|
18
|
+
# optional
|
19
|
+
@is_favourite = is_favourite
|
20
|
+
@is_active = is_active
|
21
|
+
@is_building = is_building
|
22
|
+
@average_build_time = average_build_time
|
23
|
+
@actions = actions
|
24
|
+
@stages = stages
|
25
|
+
@branches = branches
|
26
|
+
end
|
27
|
+
|
28
|
+
def builds
|
29
|
+
@builds_cache = BambooApi::Build.find_by_plan self.key if @builds_cache.nil?
|
30
|
+
@builds_cache
|
31
|
+
end
|
32
|
+
|
33
|
+
def building?
|
34
|
+
self.is_building
|
35
|
+
end
|
36
|
+
|
37
|
+
def successful?
|
38
|
+
is_successful = false
|
39
|
+
|
40
|
+
if !self.building?
|
41
|
+
is_successful = self.builds.first.successful?# rescue false
|
42
|
+
end
|
43
|
+
|
44
|
+
is_successful
|
45
|
+
end
|
46
|
+
|
47
|
+
def failed?
|
48
|
+
is_failed = false
|
49
|
+
|
50
|
+
if !self.building?
|
51
|
+
is_failed = self.builds.first.failed? rescue false
|
52
|
+
end
|
53
|
+
|
54
|
+
is_failed
|
55
|
+
end
|
56
|
+
|
57
|
+
def readable_status
|
58
|
+
if self.building?
|
59
|
+
"#{self.name} is currently building."
|
60
|
+
elsif self.successful?
|
61
|
+
"#{self.name} is currently open and it is safe to commit."
|
62
|
+
elsif self.failed?
|
63
|
+
last_build = self.builds.first
|
64
|
+
"#{self.name} is currently broken due to failing #{last_build.failing_stage.name} committed by #{ last_build.username }"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.parse plans
|
69
|
+
parsed_plans = []
|
70
|
+
|
71
|
+
plans[ "plans" ][ "plan" ].each do | plan |
|
72
|
+
parsed_plans.push( BambooApi::Plan.parse_single( plan ) )
|
73
|
+
end
|
74
|
+
|
75
|
+
parsed_plans
|
76
|
+
end
|
77
|
+
|
78
|
+
def self.parse_single plan
|
79
|
+
BambooApi::Plan.new plan[ "shortName" ], plan[ "shortKey" ], plan[ "type" ],
|
80
|
+
plan[ "enabled" ], plan[ "link" ], plan[ "key" ], plan[ "name" ], plan[ "isFavourite" ],
|
81
|
+
plan[ "isActive" ], plan[ "isBuilding" ], plan[ "averageBuildTimeInSeconds" ], plan[ "actions" ],
|
82
|
+
plan[ "stages" ], plan[ "branches" ]
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.all
|
86
|
+
BambooApi::Plan.parse( BambooApi.request "plan" )
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.find key
|
90
|
+
BambooApi::Plan.parse_single( BambooApi.request "plan/#{key}" )
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class BambooApi::Project
|
2
|
+
|
3
|
+
attr_reader :link, :key, :name
|
4
|
+
|
5
|
+
def initialize link, key, name
|
6
|
+
@link = link
|
7
|
+
@key = key
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.parse projects
|
12
|
+
parsed_projects = []
|
13
|
+
|
14
|
+
projects[ "projects" ][ "project" ].each do | project |
|
15
|
+
parsed_projects.push( BambooApi::Project.parse_single( project ) )
|
16
|
+
end
|
17
|
+
|
18
|
+
parsed_projects
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.parse_single project
|
22
|
+
BambooApi::Project.new project[ "link" ], project[ "key" ], project[ "name" ]
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.all
|
26
|
+
BambooApi::Project.parse( BambooApi.request "project" )
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.find key
|
30
|
+
BambooApi::Project.parse_single( BambooApi.request "project/#{key}" )
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class BambooApi::Stage
|
2
|
+
|
3
|
+
attr_reader :restartable, :manual, :collapsed_by_default, :display_message, :display_class, :life_cycle_state,
|
4
|
+
:state, :id, :name, :description
|
5
|
+
|
6
|
+
def initialize restartable, manual, collapsed_by_default, display_message, display_class, life_cycle_state,
|
7
|
+
state, id, name, description
|
8
|
+
|
9
|
+
@restartable = restartable
|
10
|
+
@manual = manual
|
11
|
+
@collapsed_by_default = collapsed_by_default
|
12
|
+
@display_message = display_message
|
13
|
+
@display_class = display_class
|
14
|
+
@life_cycle_state = life_cycle_state
|
15
|
+
@state = state
|
16
|
+
@id = id
|
17
|
+
@name = name
|
18
|
+
@description = description
|
19
|
+
end
|
20
|
+
|
21
|
+
def successful?
|
22
|
+
self.state == "Successful"
|
23
|
+
end
|
24
|
+
|
25
|
+
def failed?
|
26
|
+
self.state == "Failed"
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.parse stages
|
30
|
+
parsed_stages = []
|
31
|
+
stages[ "stages" ][ "stage" ].each do | stage |
|
32
|
+
parsed_stages.push( BambooApi::Stage.parse_single( stage ) )
|
33
|
+
end
|
34
|
+
|
35
|
+
parsed_stages
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.parse_single stage
|
39
|
+
BambooApi::Stage.new stage[ "restartable" ], stage[ "manual" ], stage[ "collapsedByDefault" ], stage[ "displayMessage" ],
|
40
|
+
stage[ "displayClass" ], stage[ "lifeCycleState" ], stage[ "state" ], stage[ "id" ], stage[ "name" ], stage[ "description" ]
|
41
|
+
end
|
42
|
+
end
|
data/lib/bamboo_api.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "bamboo_api/version"
|
2
|
+
require "bamboo_api/plan"
|
3
|
+
require "bamboo_api/project"
|
4
|
+
require "bamboo_api/build"
|
5
|
+
require "bamboo_api/stage"
|
6
|
+
|
7
|
+
require "rest_client"
|
8
|
+
require 'open-uri'
|
9
|
+
require 'json'
|
10
|
+
|
11
|
+
class BambooApi
|
12
|
+
|
13
|
+
def initialize options={}
|
14
|
+
@@end_point = options[ :end_point ]
|
15
|
+
@@username = options[ :username ]
|
16
|
+
@@password = options[ :password ]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.compose_url action, expand=nil
|
20
|
+
url = "https://#{@@end_point}/builds/rest/api/latest/#{action}.json?os_authType=basic&os_username=#{URI::encode( @@username )}&os_password=#{URI::encode( @@password )}"
|
21
|
+
url += "&expand=#{expand}"
|
22
|
+
url
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.request action, expand=nil
|
26
|
+
JSON.parse( RestClient.get( BambooApi.compose_url( action, expand ) ) )
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BambooApi::Build do
|
4
|
+
|
5
|
+
before( :each ) do
|
6
|
+
api = BambooApi.new( {end_point: "example.atlassian.net", username: "jorge@example.com", password: "passwordxxx" } )
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "parse user info" do
|
10
|
+
before( :each ) do
|
11
|
+
BambooApi::Build.any_instance.stub( :initialize ).and_return true
|
12
|
+
BambooApi::Build.any_instance.stub( :build_reason ).and_return 'Changes by <a href="https://example.com/builds/browse/user/john.doe@example.com">John Doe</a>'
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should parse out the username from the build reason" do
|
16
|
+
BambooApi::Build.new.parse_username.should eq "John Doe"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse out the user's url from the build reason" do
|
20
|
+
BambooApi::Build.new.parse_user_url.should eq "https://example.com/builds/browse/user/john.doe@example.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return nil if the build reason is blank" do
|
24
|
+
BambooApi::Build.any_instance.stub( :build_reason ).and_return ""
|
25
|
+
BambooApi::Build.new.parse_user_url.should eq nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "retrieve" do
|
30
|
+
it "should get all builds when calling .find_by_plan" do
|
31
|
+
VCR.use_cassette('builds.find_by_plan') do
|
32
|
+
BambooApi::Build.find_by_plan( "PHO-UAT" ).count.should eq 25
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should get a single build when calling .find" do
|
37
|
+
VCR.use_cassette('builds.find') do
|
38
|
+
build = BambooApi::Build.find( "PHO-UAT-2100" )
|
39
|
+
build.key.should eq "PHO-UAT-2100"
|
40
|
+
build.plan_name.should eq "Phoenix UAT"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "stages" do
|
46
|
+
it "should return the failing stage if the build failed" do
|
47
|
+
VCR.use_cassette('builds.find.failing') do
|
48
|
+
failing_build = BambooApi::Build.find( "PHO-CUAT-257" )
|
49
|
+
failing_build.failing_stage.nil?.should eq false
|
50
|
+
failing_build.failing_stage.id.to_s.should eq "14516313"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe "state" do
|
56
|
+
it "failed? should return true if the build failed" do
|
57
|
+
VCR.use_cassette('builds.find.failing') do
|
58
|
+
failing_build = BambooApi::Build.find( "PHO-CUAT-257" )
|
59
|
+
failing_build.failed?.should eq true
|
60
|
+
failing_build.successful?.should eq false
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
it "successful? should return true if the build failed" do
|
65
|
+
VCR.use_cassette('builds.find') do
|
66
|
+
build = BambooApi::Build.find( "PHO-UAT-2100" )
|
67
|
+
build.successful?.should eq true
|
68
|
+
build.failed?.should eq false
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe BambooApi::Plan do
|
4
|
+
|
5
|
+
before( :each ) do
|
6
|
+
api = BambooApi.new( {end_point: "example.atlassian.net", username: "jorge@example.com", password: "passwordxxx" } )
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "requests" do
|
10
|
+
|
11
|
+
it "should get all plans when calling .all" do
|
12
|
+
VCR.use_cassette('plans.all') do
|
13
|
+
BambooApi::Plan.all.count.should eq 3
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should get a single plan when calling .find" do
|
18
|
+
VCR.use_cassette('plans.find') do
|
19
|
+
plan = BambooApi::Plan.find( "PHO-UAT" )
|
20
|
+
plan.short_name.should eq "Phoenix UAT"
|
21
|
+
plan.short_key.should eq "UAT"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "states" do
|
28
|
+
# it "should return the readable state for a successful plan" do
|
29
|
+
# VCR.use_cassette('plans.find') do
|
30
|
+
# plan = BambooApi::Plan.find( "PHO-UAT" )
|
31
|
+
# plan.successful?.should eq true
|
32
|
+
# plan.readable_status.should eq "Phoenix - Phoenix UAT is currently open and it is safe to commit."
|
33
|
+
# end
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'bamboo_api'
|
5
|
+
require "multi_json"
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'vcr'
|
8
|
+
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
# Run specs in random order to surface order dependencies. If you find an
|
16
|
+
# order dependency and want to debug it, you can fix the order by providing
|
17
|
+
# the seed, which is printed after each run.
|
18
|
+
# --seed 1234
|
19
|
+
config.order = 'random'
|
20
|
+
end
|
21
|
+
|
22
|
+
VCR.configure do |c|
|
23
|
+
c.cassette_library_dir = 'spec/vcr_cassettes'
|
24
|
+
c.default_cassette_options = { record: :once, serialize_with: :json, preserve_exact_body_bytes: true, decode_compressed_response: true }
|
25
|
+
c.hook_into :webmock
|
26
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://example.atlassian.net/builds/rest/api/latest/plan.json?expand=&os_authType=basic&os_password=passwordxxx&os_username=jorge@example.com","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["*/*; q=0.5, application/xml"],"Accept-Encoding":["gzip, deflate"],"User-Agent":["Ruby"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["nginx"],"Date":["Mon, 14 Jan 2013 02:49:20 GMT"],"Content-Type":["application/json"],"Connection":["keep-alive"],"Set-Cookie":["JSESSIONID=7752B58584E50B4C2561C6D1A17F6D21; Path=/builds; HttpOnly","studio.crowd.tokenkey=\"\"; Domain=.example.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly","studio.crowd.tokenkey=yLlMt7PCEL9PqhstG1oUzw00; Domain=.example.atlassian.net; Path=/; HttpOnly"],"X-Seraph-Loginreason":["OK","OUT"],"Vary":["Accept-Encoding"],"Content-Length":["876"],"Strict-Transport-Security":["max-age=315360000;includeSubdomains"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJleHBhbmQiOiJwbGFucyIsImxpbmsiOnsiaHJlZiI6Imh0dHBzOi8vZXhh\nbXBsZS5hdGxhc3NpYW4ubmV0L2J1aWxkcy9yZXN0L2FwaS9sYXRlc3QvcGxh\nbiIsInJlbCI6InNlbGYifSwicGxhbnMiOnsic2l6ZSI6MywiZXhwYW5kIjoi\ncGxhbiIsInN0YXJ0LWluZGV4IjowLCJtYXgtcmVzdWx0IjozLCJwbGFuIjpb\neyJzaG9ydE5hbWUiOiJQaG9lbml4IEN1c3RvbWVyIFVBVCIsInNob3J0S2V5\nIjoiQ1VBVCIsInR5cGUiOiJjaGFpbiIsImVuYWJsZWQiOnRydWUsImxpbmsi\nOnsiaHJlZiI6Imh0dHBzOi8vZXhhbXBsZS5hdGxhc3NpYW4ubmV0L2J1aWxk\ncy9yZXN0L2FwaS9sYXRlc3QvcGxhbi9QSE8tQ1VBVCIsInJlbCI6InNlbGYi\nfSwia2V5IjoiUEhPLUNVQVQiLCJuYW1lIjoiUGhvZW5peCAtIFBob2VuaXgg\nQ3VzdG9tZXIgVUFUIn0seyJzaG9ydE5hbWUiOiJQaG9lbml4IFNhbGVzIERF\nTU8iLCJzaG9ydEtleSI6IlNERU1PIiwidHlwZSI6ImNoYWluIiwiZW5hYmxl\nZCI6dHJ1ZSwibGluayI6eyJocmVmIjoiaHR0cHM6Ly9leGFtcGxlLmF0bGFz\nc2lhbi5uZXQvYnVpbGRzL3Jlc3QvYXBpL2xhdGVzdC9wbGFuL1BITy1TREVN\nTyIsInJlbCI6InNlbGYifSwia2V5IjoiUEhPLVNERU1PIiwibmFtZSI6IlBo\nb2VuaXggLSBQaG9lbml4IFNhbGVzIERFTU8ifSx7InNob3J0TmFtZSI6IlBo\nb2VuaXggVUFUIiwic2hvcnRLZXkiOiJVQVQiLCJ0eXBlIjoiY2hhaW4iLCJl\nbmFibGVkIjp0cnVlLCJsaW5rIjp7ImhyZWYiOiJodHRwczovL2V4YW1wbGUu\nYXRsYXNzaWFuLm5ldC9idWlsZHMvcmVzdC9hcGkvbGF0ZXN0L3BsYW4vUEhP\nLVVBVCIsInJlbCI6InNlbGYifSwia2V5IjoiUEhPLVVBVCIsIm5hbWUiOiJQ\naG9lbml4IC0gUGhvZW5peCBVQVQifV19fQ==\n"},"http_version":null},"recorded_at":"Mon, 14 Jan 2013 02:49:20 GMT"}],"recorded_with":"VCR 2.2.5"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"http_interactions":[{"request":{"method":"get","uri":"https://example.atlassian.net/builds/rest/api/latest/plan/PHO-UAT.json?expand=&os_authType=basic&os_password=passwordxxx&os_username=jorge@example.com","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["*/*; q=0.5, application/xml"],"Accept-Encoding":["gzip, deflate"],"User-Agent":["Ruby"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["nginx"],"Date":["Mon, 14 Jan 2013 02:49:21 GMT"],"Content-Type":["application/json"],"Connection":["keep-alive"],"Set-Cookie":["JSESSIONID=A760241903C8C57DEFA02E1BF5B7AA13; Path=/builds; HttpOnly","studio.crowd.tokenkey=\"\"; Domain=.example.atlassian.net; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly","studio.crowd.tokenkey=yLlMt7PCEL9PqhstG1oUzw00; Domain=.example.atlassian.net; Path=/; HttpOnly"],"X-Seraph-Loginreason":["OK","OUT"],"Vary":["Accept-Encoding"],"Content-Length":["602"],"Strict-Transport-Security":["max-age=315360000;includeSubdomains"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJleHBhbmQiOiJhY3Rpb25zLHN0YWdlcyxicmFuY2hlcyx2YXJpYWJsZUNv\nbnRleHQiLCJwcm9qZWN0S2V5IjoiUEhPIiwicHJvamVjdE5hbWUiOiJQaG9l\nbml4Iiwic2hvcnROYW1lIjoiUGhvZW5peCBVQVQiLCJzaG9ydEtleSI6IlVB\nVCIsInR5cGUiOiJjaGFpbiIsImVuYWJsZWQiOnRydWUsImxpbmsiOnsiaHJl\nZiI6Imh0dHBzOi8vZXhhbXBsZS5hdGxhc3NpYW4ubmV0L2J1aWxkcy9yZXN0\nL2FwaS9sYXRlc3QvcGxhbi9QSE8tVUFUIiwicmVsIjoic2VsZiJ9LCJpc0Zh\ndm91cml0ZSI6dHJ1ZSwiaXNBY3RpdmUiOmZhbHNlLCJpc0J1aWxkaW5nIjpm\nYWxzZSwiYXZlcmFnZUJ1aWxkVGltZUluU2Vjb25kcyI6MjY0MS4wLCJhY3Rp\nb25zIjp7InNpemUiOjQsInN0YXJ0LWluZGV4IjowLCJtYXgtcmVzdWx0Ijo0\nfSwic3RhZ2VzIjp7InNpemUiOjgsInN0YXJ0LWluZGV4IjowLCJtYXgtcmVz\ndWx0Ijo4fSwiYnJhbmNoZXMiOnsic2l6ZSI6MCwic3RhcnQtaW5kZXgiOjAs\nIm1heC1yZXN1bHQiOjB9LCJ2YXJpYWJsZUNvbnRleHQiOnsic2l6ZSI6MCwi\nbWF4LXJlc3VsdHMiOjB9LCJrZXkiOiJQSE8tVUFUIiwibmFtZSI6IlBob2Vu\naXggLSBQaG9lbml4IFVBVCJ9\n"},"http_version":null},"recorded_at":"Mon, 14 Jan 2013 02:49:21 GMT"}],"recorded_with":"VCR 2.2.5"}
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bamboo_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jorge Valdivia
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: multi_json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: vcr
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: webmock
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rest-client
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :runtime
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
description: Atlassian Bamboo API Wrapper
|
95
|
+
email:
|
96
|
+
- jorge@valdivia.me
|
97
|
+
executables: []
|
98
|
+
extensions: []
|
99
|
+
extra_rdoc_files: []
|
100
|
+
files:
|
101
|
+
- .gitignore
|
102
|
+
- .rspec
|
103
|
+
- Gemfile
|
104
|
+
- LICENSE.txt
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- bamboo_api.gemspec
|
108
|
+
- lib/bamboo_api.rb
|
109
|
+
- lib/bamboo_api/build.rb
|
110
|
+
- lib/bamboo_api/plan.rb
|
111
|
+
- lib/bamboo_api/project.rb
|
112
|
+
- lib/bamboo_api/stage.rb
|
113
|
+
- lib/bamboo_api/version.rb
|
114
|
+
- spec/bamboo_api/build_spec.rb
|
115
|
+
- spec/bamboo_api/plan_spec.rb
|
116
|
+
- spec/bamboo_api_spec.rb
|
117
|
+
- spec/spec_helper.rb
|
118
|
+
- spec/vcr_cassettes/plans_all.json
|
119
|
+
- spec/vcr_cassettes/plans_find.json
|
120
|
+
homepage: https://github.com/jorgevaldivia/bamboo_api
|
121
|
+
licenses: []
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
133
|
+
none: false
|
134
|
+
requirements:
|
135
|
+
- - ! '>='
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
requirements: []
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.8.22
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: A simple wrapper for Atlassian's Bamboo's REST API.
|
144
|
+
test_files:
|
145
|
+
- spec/bamboo_api/build_spec.rb
|
146
|
+
- spec/bamboo_api/plan_spec.rb
|
147
|
+
- spec/bamboo_api_spec.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
- spec/vcr_cassettes/plans_all.json
|
150
|
+
- spec/vcr_cassettes/plans_find.json
|