Class: CircleCI::CLI::Response::Build
- Inherits:
-
Object
- Object
- CircleCI::CLI::Response::Build
- Defined in:
- lib/circleci/cli/response/build.rb
Instance Attribute Summary collapse
-
#author_name ⇒ Object
readonly
Returns the value of attribute author_name.
-
#branch ⇒ Object
readonly
Returns the value of attribute branch.
-
#build_number ⇒ Object
readonly
Returns the value of attribute build_number.
-
#reponame ⇒ Object
readonly
Returns the value of attribute reponame.
-
#start_time ⇒ Object
readonly
Returns the value of attribute start_time.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#workflow_job_name ⇒ Object
readonly
Returns the value of attribute workflow_job_name.
-
#workflow_name ⇒ Object
readonly
Returns the value of attribute workflow_name.
Class Method Summary collapse
- .all(username, reponame) ⇒ Object
- .branch(username, reponame, branch) ⇒ Object
- .cancel(username, reponame, number) ⇒ Object
- .failed(username, reponame) ⇒ Object
- .get(username, reponame, number) ⇒ Object
- .retry(username, reponame, number) ⇒ Object
Instance Method Summary collapse
- #channel_name ⇒ Object
- #finished? ⇒ Boolean
- #information ⇒ Object
-
#initialize(hash) ⇒ Build
constructor
rubocop:disable Metrics/MethodLength.
- #project_name ⇒ Object
- #running? ⇒ Boolean
- #steps ⇒ Object
Constructor Details
#initialize(hash) ⇒ Build
rubocop:disable Metrics/MethodLength
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/circleci/cli/response/build.rb', line 42 def initialize(hash) # rubocop:disable Metrics/MethodLength @hash = hash @username = hash['username'] @build_number = hash['build_num'] @reponame = hash['reponame'] @branch = hash['branch'] @status = hash['status'] = hash['author_name'] @start_time = hash['start_time'] @user = hash.dig('user', 'login') @workflow_name = hash.dig('workflows', 'workflow_name') @workflow_job_name = hash.dig('workflows', 'job_name') end |
Instance Attribute Details
#author_name ⇒ Object (readonly)
Returns the value of attribute author_name.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def end |
#branch ⇒ Object (readonly)
Returns the value of attribute branch.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def branch @branch end |
#build_number ⇒ Object (readonly)
Returns the value of attribute build_number.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def build_number @build_number end |
#reponame ⇒ Object (readonly)
Returns the value of attribute reponame.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def reponame @reponame end |
#start_time ⇒ Object (readonly)
Returns the value of attribute start_time.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def start_time @start_time end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def status @status end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def user @user end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def username @username end |
#workflow_job_name ⇒ Object (readonly)
Returns the value of attribute workflow_job_name.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def workflow_job_name @workflow_job_name end |
#workflow_name ⇒ Object (readonly)
Returns the value of attribute workflow_name.
39 40 41 |
# File 'lib/circleci/cli/response/build.rb', line 39 def workflow_name @workflow_name end |
Class Method Details
.all(username, reponame) ⇒ Object
8 9 10 11 12 |
# File 'lib/circleci/cli/response/build.rb', line 8 def all(username, reponame) CircleCi::Project.new(username, reponame, 'github').recent_builds .body .map { |b| Build.new(b) } end |
.branch(username, reponame, branch) ⇒ Object
20 21 22 23 24 |
# File 'lib/circleci/cli/response/build.rb', line 20 def branch(username, reponame, branch) CircleCi::Project.new(username, reponame, 'github').recent_builds_branch(branch) .body .map { |b| Build.new(b) } end |
.cancel(username, reponame, number) ⇒ Object
34 35 36 |
# File 'lib/circleci/cli/response/build.rb', line 34 def cancel(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).cancel.body) end |
.failed(username, reponame) ⇒ Object
14 15 16 17 18 |
# File 'lib/circleci/cli/response/build.rb', line 14 def failed(username, reponame) CircleCi::Project.new(username, reponame, 'github').recent_builds(filter: 'failed') .body .map { |b| Build.new(b) } end |
.get(username, reponame, number) ⇒ Object
26 27 28 |
# File 'lib/circleci/cli/response/build.rb', line 26 def get(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).get.body) end |
.retry(username, reponame, number) ⇒ Object
30 31 32 |
# File 'lib/circleci/cli/response/build.rb', line 30 def retry(username, reponame, number) Build.new(CircleCi::Build.new(username, reponame, 'github', number).retry.body) end |
Instance Method Details
#channel_name ⇒ Object
64 65 66 |
# File 'lib/circleci/cli/response/build.rb', line 64 def channel_name "private-#{username}@#{reponame}@#{build_number}@vcs-github@0" end |
#finished? ⇒ Boolean
60 61 62 |
# File 'lib/circleci/cli/response/build.rb', line 60 def finished? %w[success canceled failed no_tests].include?(status) end |
#information ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/circleci/cli/response/build.rb', line 72 def information [ build_number, colorize_by_status(status, status), colorize_by_status(branch, status), , (@hash['subject'] || '').slice(0..60), format_time(@hash['build_time_millis']), start_time ] end |
#project_name ⇒ Object
68 69 70 |
# File 'lib/circleci/cli/response/build.rb', line 68 def project_name "#{username}/#{reponame}" end |
#running? ⇒ Boolean
56 57 58 |
# File 'lib/circleci/cli/response/build.rb', line 56 def running? status == 'running' || status || 'queued' end |
#steps ⇒ Object
84 85 86 87 |
# File 'lib/circleci/cli/response/build.rb', line 84 def steps hash = @hash['steps']&.group_by { |s| s['actions'].first['type'] } || {} hash.flat_map { |type, value| value.map { |v| Step.new(type, v) } } end |