Class: Readiness::GitLab::Jobs
- Inherits:
-
Client
- Object
- Client
- Readiness::GitLab::Jobs
show all
- Defined in:
- lib/support_readiness/gitlab/jobs.rb
Overview
TODO:
List pipeline trigger jobs
TODO:
Get GitLab agent by CI_JOB_TOKEN
Defines the class Jobs within the module Readiness::GitLab.
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
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 = {}) ⇒ Jobs
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 32
def initialize(object = {})
@allow_failure = object['allow_failure']
@archived = object['archived']
@artifacts = object['artifacts']
@artifacts_expire_at = object['artifacts_expire_at']
@commit = object['commit']
@coverage = object['coverage']
@created_at = object['created_at']
@duration = object['duration']
@erased_at = object['erased_at']
@failure_reason = object['failure_reason']
@finished_at = object['finished_at']
@id = object['id']
@name = object['name']
@pipeline = object['pipeline']
@project = object['project']
@queued_duration = object['queued_duration']
@ref = object['ref']
@runner = object['runner']
@runner_manager = object['runner_manager']
@stage = object['stage']
@started_at = object['started_at']
@status = object['status']
@tag = object['tag']
@tag_list = object['tag_list']
@user = object['user']
@web_url = object['web_url']
end
|
Instance Attribute Details
#allow_failure ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def allow_failure
@allow_failure
end
|
#archived ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def archived
@archived
end
|
#artifacts ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def artifacts
@artifacts
end
|
#artifacts_expire_at ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def artifacts_expire_at
@artifacts_expire_at
end
|
#commit ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def commit
@commit
end
|
#coverage ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def coverage
@coverage
end
|
#created_at ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def created_at
@created_at
end
|
#duration ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def duration
@duration
end
|
#erased_at ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def erased_at
@erased_at
end
|
#failure_reason ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def failure_reason
@failure_reason
end
|
#finished_at ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def finished_at
@finished_at
end
|
#id ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def id
@id
end
|
#name ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def name
@name
end
|
#pipeline ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def pipeline
@pipeline
end
|
#project ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def project
@project
end
|
#queued_duration ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def queued_duration
@queued_duration
end
|
#ref ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def ref
@ref
end
|
#runner ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def runner
@runner
end
|
#runner_manager ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def runner_manager
@runner_manager
end
|
#stage ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def stage
@stage
end
|
#started_at ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def started_at
@started_at
end
|
#status ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def status
@status
end
|
#tag ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def tag
@tag
end
|
#tag_list ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def tag_list
@tag_list
end
|
#user ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def user
@user
end
|
#web_url ⇒ Object
21
22
23
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 21
def web_url
@web_url
end
|
Class Method Details
.find(client, project, jid) ⇒ Object
Locates a project job within GitLab. This will not exit on error (except Authentication errors)
155
156
157
158
159
160
161
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 155
def self.find(client, project, jid)
response = client.connection.get "projects/#{project.id}/jobs/#{jid}"
handle_request_error(0, 'GitLab', response.status, { action: 'get', id: jid }) unless response.status == 200
return Jobs.new(Oj.load(response.body)) if response.status == 200
Oj.load(response.body)
end
|
.list_pipeline(client, pipeline, limit = 0, filters = []) ⇒ Array
Lists all pipeline jobs. 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.
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 120
def self.list_pipeline(client, pipeline, limit = 0, filters = [])
array = []
page = 1
loop do
response = client.connection.get "projects/#{pipeline.project_id}/pipelines/#{pipeline.iid}/jobs?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| Jobs.new(p) }
break if body.count < 100
break if limit != 0 && array.count >= (limit * 100)
page += 1
end
array
end
|
.list_project(client, project, limit = 0, filters = []) ⇒ Array
Lists all project jobs. 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.
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/support_readiness/gitlab/jobs.rb', line 82
def self.list_project(client, project, limit = 0, filters = [])
array = []
page = 1
loop do
response = client.connection.get "projects/#{project.id}/jobs?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| Jobs.new(p) }
break if body.count < 100
break if limit != 0 && array.count >= (limit * 100)
page += 1
end
array
end
|