Class: BambooApi::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/bamboo_api/build.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(restartable, once_off, continuable, id, number, life_cycle_state, state, key, link, plan_name, project_name, build_started_time, build_completed_time, build_duration_in_seconds, vcs_revision_key, build_test_summary, successful_test_count, failed_test_count, quarantined_test_count, build_reason, stages) ⇒ Build

Returns a new instance of Build.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bamboo_api/build.rb', line 9

def initialize restartable, once_off, continuable, id, number, life_cycle_state, state, key,
  link, plan_name, project_name, build_started_time, build_completed_time, build_duration_in_seconds,
  vcs_revision_key, build_test_summary, successful_test_count, failed_test_count,
  quarantined_test_count, build_reason, stages

  @restartable = restartable
  @once_off = once_off
  @continuable = continuable
  @id = id
  @number = number
  @life_cycle_state = life_cycle_state
  @state = state
  @key = key
  @link = link
  @plan_name = plan_name
  @build_started_time = build_started_time
  @build_completed_time = build_completed_time
  @build_duration_in_seconds = build_duration_in_seconds
  @revision = @vcs_revision_key = vcs_revision_key
  @build_test_summary = build_test_summary
  @successful_test_count = successful_test_count
  @failed_test_count = failed_test_count
  @quarantined_test_count = quarantined_test_count
  @build_reason = build_reason
  @user_url = user_url
  @username = username
  @stages = stages

  @user_url = parse_user_url
  @username = parse_username
end

Instance Attribute Details

#build_completed_timeObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def build_completed_time
  @build_completed_time
end

#build_duration_in_secondsObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def build_duration_in_seconds
  @build_duration_in_seconds
end

#build_reasonObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def build_reason
  @build_reason
end

#build_started_timeObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def build_started_time
  @build_started_time
end

#build_test_summaryObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def build_test_summary
  @build_test_summary
end

#continuableObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def continuable
  @continuable
end

#failed_test_countObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def failed_test_count
  @failed_test_count
end

#idObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def id
  @id
end

#keyObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def key
  @key
end

#life_cycle_stateObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def life_cycle_state
  @life_cycle_state
end

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def link
  @link
end

#numberObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def number
  @number
end

#once_offObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def once_off
  @once_off
end

#plan_nameObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def plan_name
  @plan_name
end

#project_nameObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def project_name
  @project_name
end

#quarantined_test_countObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def quarantined_test_count
  @quarantined_test_count
end

#restartableObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def restartable
  @restartable
end

#revisionObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def revision
  @revision
end

#stagesObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def stages
  @stages
end

#stateObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def state
  @state
end

#successful_test_countObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def successful_test_count
  @successful_test_count
end

#user_urlObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def user_url
  @user_url
end

#usernameObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def username
  @username
end

#vcs_revision_keyObject (readonly)

/result/PHO-UAT



4
5
6
# File 'lib/bamboo_api/build.rb', line 4

def vcs_revision_key
  @vcs_revision_key
end

Class Method Details

.allObject



87
88
89
# File 'lib/bamboo_api/build.rb', line 87

def self.all
  raise "You must use the method find_by_plan. Sorry."
end

.find(key) ⇒ Object



91
92
93
# File 'lib/bamboo_api/build.rb', line 91

def self.find key
  BambooApi::Build.parse_single( BambooApi.request "result/#{key}", "stages" )
end

.find_by_plan(plan_key) ⇒ Object



95
96
97
# File 'lib/bamboo_api/build.rb', line 95

def self.find_by_plan plan_key
  BambooApi::Build.parse( BambooApi.request "result/#{plan_key}", "results.result.stages" )
end

.parse(builds) ⇒ Object



69
70
71
72
73
74
75
76
77
# File 'lib/bamboo_api/build.rb', line 69

def self.parse builds
  parsed_builds = []

  builds[ "results" ][ "result" ].each do | build |
    parsed_builds.push( BambooApi::Build.parse_single( build ) )
  end

  parsed_builds
end

.parse_single(build) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/bamboo_api/build.rb', line 79

def self.parse_single build
  stages = BambooApi::Stage.parse( build )
  BambooApi::Build.new build[ "restartable" ], build[ "onceOff" ], build[ "continuable" ], build[ "id" ], build[ "number" ], build[ "lifeCycleState" ],
    build[ "state" ], build[ "key" ], build[ "link" ], build[ "planName" ], build[ "projectName" ], build[ "buildStartedTime" ], 
    build[ "buildCompletedTime" ], build[ "buildDurationInSeconds" ], build[ "vcsRevisionKey" ], build[ "buildTestSummary" ], 
    build[ "successfulTestCount" ], build[ "failedTestCount" ], build[ "quarantinedTestCount" ], build[ "buildReason" ], stages
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/bamboo_api/build.rb', line 53

def failed?
  self.state == "Failed"
end

#failing_stageObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/bamboo_api/build.rb', line 57

def failing_stage
  failing = nil
  self.stages.each do | stage |
    if stage.failed?
      failing = stage
      break
    end
  end

  failing
end

#parse_user_urlObject



45
46
47
# File 'lib/bamboo_api/build.rb', line 45

def parse_user_url
  self.build_reason.scan(/href="(.*)"/).flatten.first if !build_reason.nil? && !build_reason.empty?
end

#parse_usernameObject



41
42
43
# File 'lib/bamboo_api/build.rb', line 41

def parse_username
  self.build_reason.scan(/>(.*)</).flatten.first if !build_reason.nil? && !build_reason.empty?
end

#successful?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/bamboo_api/build.rb', line 49

def successful?
  self.state == "Successful"
end