Class: Readiness::GitLab::Pipelines
- Defined in:
- lib/support_readiness/gitlab/pipelines.rb
Overview
Get a pipeline’s test report
Get a pipeline’s test report summary
Create a new pipeline
Retry jobs in a pipeline
Cancel a pipeline’s jobs
Delete a pipeline
Update pipeline metadata
Defines the class Pipelines within the module Readiness::GitLab.
Instance Attribute Summary collapse
- #created_at ⇒ Object
- #id ⇒ Object
- #iid ⇒ Object
- #name ⇒ Object
- #project_id ⇒ Object
- #ref ⇒ Object
- #sha ⇒ Object
- #source ⇒ Object
- #status ⇒ Object
- #updated_at ⇒ Object
- #web_url ⇒ Object
Class Method Summary collapse
-
.find(client, project, pid) ⇒ Hash
Locates a project pipeline within GitLab.
-
.find!(client, project, pid) ⇒ Object
Locates a project pipeline within GitLab.
-
.jobs(client, pipeline, limit = 0, filters = []) ⇒ Array
Lists all pipeline jobs.
-
.list(client, project, limit = 0, filters = []) ⇒ Array
Lists all pipelines for an object.
-
.variables(client, pipeline) ⇒ Hash
Gets the variables for a pipeline.
Instance Method Summary collapse
-
#initialize(object = {}) ⇒ Pipelines
constructor
Creates a new Pipelines instance.
Methods inherited from Client
auth_error, bad_request_error, convert_actions, convert_conditions, convert_standard_names_to_ids, convert_ticket_form_agent_conditions, convert_ticket_form_brands, convert_ticket_form_end_user_conditions, convert_ticket_form_names_to_ids, convert_view_names_to_ids, convert_view_restrictions, covert_ticket_form_field_ids, create_package!, erb_renderer, handle_request_error, not_found_error, not_processible_error, put_into_archive, recursively_deflate_directory, timestamp_filename, to_clean_json, to_clean_json_with_key, to_hash, to_nearly_clean_json, to_nearly_clean_json_with_key, to_param_string, write_entries
Constructor Details
#initialize(object = {}) ⇒ Pipelines
Creates a new Readiness::GitLab::Pipelines instance
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 31 def initialize(object = {}) @created_at = object['created_at'] @id = object['id'] @iid = object['iid'] @name = object['name'] @project_id = object['project_id'] @ref = object['ref'] @sha = object['sha'] @source = object['source'] @status = object['status'] @updated_at = object['updated_at'] @web_url = object['web_url'] end |
Instance Attribute Details
#created_at ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def created_at @created_at end |
#id ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def id @id end |
#iid ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def iid @iid end |
#name ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def name @name end |
#project_id ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def project_id @project_id end |
#ref ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def ref @ref end |
#sha ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def sha @sha end |
#source ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def source @source end |
#status ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def status @status end |
#updated_at ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def updated_at @updated_at end |
#web_url ⇒ Object
20 21 22 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 20 def web_url @web_url end |
Class Method Details
.find(client, project, pid) ⇒ Hash
Locates a project pipeline within GitLab. This will not exit on error (except Authentication errors)
101 102 103 104 105 106 107 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 101 def self.find(client, project, pid) response = client.connection.get "projects/#{project.id}/pipelines/#{pid}" handle_request_error(0, 'GitLab', response.status, { action: 'get', id: pid }) unless response.status == 200 return Pipelines.new(Oj.load(response.body)) if response.status == 200 Oj.load(response.body) end |
.find!(client, project, pid) ⇒ Object
Locates a project pipeline within GitLab. This will exit on error
128 129 130 131 132 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 128 def self.find!(client, project, pid) response = client.connection.get "projects/#{project.id}/pipelines/#{pid}" handle_request_error(1, 'GitLab', response.status, { action: 'Find pipeline', id: pid }) unless response.status == 200 Pipelines.new(Oj.load(response.body)) end |
.jobs(client, pipeline, limit = 0, filters = []) ⇒ Array
Lists all pipeline jobs. This is a wrapper of Jobs.list_pipeline
186 187 188 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 186 def self.jobs(client, pipeline, limit = 0, filters = []) Jobs.list_pipeline(client, pipeline, limit, filters) end |
.list(client, project, limit = 0, filters = []) ⇒ Array
Lists all pipelines for an object. Does not stop until it ends or the page limit is hit. This method can take a long time to run depending on the parameters used.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 66 def self.list(client, project, limit = 0, filters = []) array = [] page = 1 loop do response = client.connection.get "projects/#{project.id}/pipelines?per_page=100&page=#{page}&#{to_param_string(filters)}" handle_request_error(0, 'GitLab', response.status) unless response.status == 200 body = Oj.load(response.body) array += body.map { |p| Pipelines.new(p) } break if body.count < 100 break if limit != 0 && array.count >= (limit * 100) page += 1 end array end |
.variables(client, pipeline) ⇒ Hash
Gets the variables for a pipeline.
159 160 161 162 163 |
# File 'lib/support_readiness/gitlab/pipelines.rb', line 159 def self.variables(client, pipeline) response = client.connection.get "projects/#{pipeline.project_id}/pipleines/#{pipeline.iid}/variables" handle_request_error(0, 'GitLab', response.status, { action: 'get', id: pid }) unless response.status == 200 Oj.load(response.body) end |