Class: LabClient::Jobs
- Inherits:
-
Common
show all
- Defined in:
- lib/labclient/jobs/keep.rb,
lib/labclient/jobs/play.rb,
lib/labclient/jobs/show.rb,
lib/labclient/jobs/erase.rb,
lib/labclient/jobs/retry.rb,
lib/labclient/jobs/trace.rb,
lib/labclient/jobs/cancel.rb,
lib/labclient/jobs/delete.rb,
lib/labclient/jobs/artifacts.rb,
lib/labclient/jobs/project_list.rb,
lib/labclient/jobs/pipeline_list.rb,
lib/labclient/jobs/artifacts_path.rb,
lib/labclient/jobs/artifacts_latest.rb
Overview
Constant Summary
Constants included
from AccessLevel
AccessLevel::HUMAN_ACCESS_LEVELS, AccessLevel::MACHINE_ACCESS_LEVELS
Instance Attribute Summary
Attributes inherited from Common
#client
Instance Method Summary
collapse
-
#artifacts(project_id, job_id, job_token = nil) ⇒ Object
-
#artifacts_latest(project_id, branch_name, job_name, file_path = nil, job_token = nil) ⇒ Object
-
#artifacts_path(project_id, job_id, artifact_path, file_path = nil) ⇒ Object
-
#cancel(project_id, job_id) ⇒ Object
-
#delete(project_id, job_id) ⇒ Object
-
#download_artifacts(project_id, job_id, file_path = nil, job_token = nil) ⇒ Object
Helper to write immediately to a file.
-
#erase(project_id, job_id) ⇒ Object
-
#keep(project_id, job_id) ⇒ Object
-
#pipeline(project_id, pipeline_id, scope = nil) ⇒ Object
-
#play(project_id, job_id) ⇒ Object
-
#project(project_id, scope = nil) ⇒ Object
-
#retry(project_id, job_id) ⇒ Object
-
#show(project_id, job_id) ⇒ Object
-
#trace(project_id, job_id) ⇒ Object
Methods inherited from Common
#api_methods, #api_methods_help, #format_id, #format_query_id, #format_query_ids, #format_time?, #group_name, #help, #initialize, #inspect, #klass, #protected_query_access_level, #query_access_level, #query_format_time
Methods included from Docs
#demo, #desc, #doc, docs, #example, #group_name, #help, json, #markdown, #navigation, #option, #result, #subtitle, #title
#human_access_level, #human_protected_access_level, #machine_access_level, #machine_protected_access_level
Instance Method Details
#artifacts(project_id, job_id, job_token = nil) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/labclient/jobs/artifacts.rb', line 45
def artifacts(project_id, job_id, job_token = nil)
job_id = format_id(job_id)
project_id = format_id(project_id)
query = { job_token: job_token } if job_token
client.request(:get, "projects/#{project_id}/jobs/#{job_id}/artifacts", LabFile, query)
end
|
#artifacts_latest(project_id, branch_name, job_name, file_path = nil, job_token = nil) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/labclient/jobs/artifacts_latest.rb', line 28
def artifacts_latest(project_id, branch_name, job_name, file_path = nil, job_token = nil)
query = { job: job_name }
query[:job_token] = job_token if job_token
file_path ||= "#{Dir.pwd}/#{job_name}.zip"
project_id = format_id(project_id)
output = client.request(:get, "projects/#{project_id}/jobs/artifacts/#{branch_name}/download", nil, query)
File.write(file_path, output)
end
|
#artifacts_path(project_id, job_id, artifact_path, file_path = nil) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/labclient/jobs/artifacts_path.rb', line 40
def artifacts_path(project_id, job_id, artifact_path, file_path = nil)
job_id = format_id(job_id)
project_id = format_id(project_id)
file_path ||= "#{Dir.pwd}/#{artifact_path}"
output = client.request(:get, "projects/#{project_id}/jobs/#{job_id}/artifacts/#{artifact_path}", nil)
File.write(file_path, output)
end
|
#cancel(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/cancel.rb', line 27
def cancel(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:post, "projects/#{project_id}/jobs/#{job_id}/cancel", Job)
end
|
#delete(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/delete.rb', line 27
def delete(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:delete, "projects/#{project_id}/jobs/#{job_id}/artifacts")
end
|
#download_artifacts(project_id, job_id, file_path = nil, job_token = nil) ⇒ Object
Helper to write immediately to a file
55
56
57
58
59
60
61
62
63
|
# File 'lib/labclient/jobs/artifacts.rb', line 55
def download_artifacts(project_id, job_id, file_path = nil, job_token = nil)
file_path ||= "#{Dir.pwd}/#{job_id}.zip"
output = artifacts(project_id, job_id, job_token)
File.write(file_path, output.data) if output.success?
output
end
|
#erase(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/erase.rb', line 27
def erase(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:post, "projects/#{project_id}/jobs/#{job_id}/erase", Job)
end
|
#keep(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/keep.rb', line 27
def keep(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:post, "projects/#{project_id}/jobs/#{job_id}/keep", Job)
end
|
#pipeline(project_id, pipeline_id, scope = nil) ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/labclient/jobs/pipeline_list.rb', line 24
def pipeline(project_id, pipeline_id, scope = nil)
pipeline_id = format_id(pipeline_id)
project_id = format_id(project_id)
query = { scope: scope } if scope
client.request(:get, "projects/#{project_id}/pipelines/#{pipeline_id}/jobs", Job, query)
end
|
#play(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/play.rb', line 27
def play(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:post, "projects/#{project_id}/jobs/#{job_id}/play", Job)
end
|
#project(project_id, scope = nil) ⇒ Object
24
25
26
27
28
|
# File 'lib/labclient/jobs/project_list.rb', line 24
def project(project_id, scope = nil)
project_id = format_id(project_id)
query = { scope: scope } if scope
client.request(:get, "projects/#{project_id}/jobs", Job, query)
end
|
#retry(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/retry.rb', line 27
def retry(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:post, "projects/#{project_id}/jobs/#{job_id}/retry", Job)
end
|
#show(project_id, job_id) ⇒ Object
19
20
21
22
23
|
# File 'lib/labclient/jobs/show.rb', line 19
def show(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:get, "projects/#{project_id}/jobs/#{job_id}", Job)
end
|
#trace(project_id, job_id) ⇒ Object
27
28
29
30
31
|
# File 'lib/labclient/jobs/trace.rb', line 27
def trace(project_id, job_id)
job_id = format_id(job_id)
project_id = format_id(project_id)
client.request(:get, "projects/#{project_id}/jobs/#{job_id}/trace")
end
|