Module: Gitlab::Client::Jobs
- Included in:
- Gitlab::Client
- Defined in:
- lib/gitlab/client/jobs.rb
Overview
Defines methods related to projects.
Instance Method Summary collapse
-
#download_branch_artifact_file(project_id, ref_name, artifact_path, job) ⇒ Gitlab::FileResponse
(also: #download_tag_artifact_file)
Download a single artifact file from specific tag or branch.
-
#download_job_artifact_file(project_id, job_id, artifact_path) ⇒ Gitlab::FileResponse
Download a single artifact file by job ID.
-
#job(project_id, job_id) ⇒ Object
Gets a single job.
-
#job_artifacts(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Gets artifacts from a job.
-
#job_artifacts_delete(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Delete Artifacts Deletes the artifacts associated with a job.
-
#job_artifacts_download(project_id, ref_name, job_name) ⇒ Gitlab::FileResponse
Download Job Artifact.
-
#job_artifacts_keep(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Keep Artifacts Prevents artifacts from being deleted when expiration is set.
-
#job_cancel(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Cancel a job.
-
#job_erase(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Erase Job.
-
#job_play(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Play a Job Triggers a manual action to start a job.
-
#job_retry(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Retry a job.
-
#job_trace(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Get Job Trace.
-
#jobs(project_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Jobs for a Project.
-
#pipeline_bridges(project_id, pipeline_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Bridge Jobs from a pipeline.
-
#pipeline_jobs(project_id, pipeline_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Jobs from a pipeline.
Instance Method Details
#download_branch_artifact_file(project_id, ref_name, artifact_path, job) ⇒ Gitlab::FileResponse Also known as: download_tag_artifact_file
Download a single artifact file from specific tag or branch
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/gitlab/client/jobs.rb', line 138 def download_branch_artifact_file(project_id, ref_name, artifact_path, job) get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/raw/#{artifact_path}", query: { job: job }, format: nil, headers: { Accept: 'application/octet-stream' }, parser: proc { |body, _| if body.encoding == Encoding::ASCII_8BIT # binary response ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') else # error with json response ::Gitlab::Request.parse(body) end }) end |
#download_job_artifact_file(project_id, job_id, artifact_path) ⇒ Gitlab::FileResponse
Download a single artifact file by job ID
115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/gitlab/client/jobs.rb', line 115 def download_job_artifact_file(project_id, job_id, artifact_path) get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/#{artifact_path}", format: nil, headers: { Accept: 'application/octet-stream' }, parser: proc { |body, _| if body.encoding == Encoding::ASCII_8BIT # binary response ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') else # error with json response ::Gitlab::Request.parse(body) end }) end |
#job(project_id, job_id) ⇒ Object
Gets a single job
62 63 64 |
# File 'lib/gitlab/client/jobs.rb', line 62 def job(project_id, job_id) get("/projects/#{url_encode project_id}/jobs/#{job_id}") end |
#job_artifacts(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Gets artifacts from a job
75 76 77 78 79 80 |
# File 'lib/gitlab/client/jobs.rb', line 75 def job_artifacts(project_id, job_id) get("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts", format: nil, headers: { Accept: 'text/plain' }, parser: ::Gitlab::Request::Parser) end |
#job_artifacts_delete(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Delete Artifacts Deletes the artifacts associated with a job.
246 247 248 |
# File 'lib/gitlab/client/jobs.rb', line 246 def job_artifacts_delete(project_id, job_id) delete("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts") end |
#job_artifacts_download(project_id, ref_name, job_name) ⇒ Gitlab::FileResponse
Download Job Artifact
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/gitlab/client/jobs.rb', line 92 def job_artifacts_download(project_id, ref_name, job_name) get("/projects/#{url_encode project_id}/jobs/artifacts/#{ref_name}/download", query: { job: job_name }, format: nil, headers: { Accept: 'application/octet-stream' }, parser: proc { |body, _| if body.encoding == Encoding::ASCII_8BIT # binary response ::Gitlab::FileResponse.new StringIO.new(body, 'rb+') else # error with json response ::Gitlab::Request.parse(body) end }) end |
#job_artifacts_keep(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Keep Artifacts Prevents artifacts from being deleted when expiration is set.
232 233 234 |
# File 'lib/gitlab/client/jobs.rb', line 232 def job_artifacts_keep(project_id, job_id) post("/projects/#{url_encode project_id}/jobs/#{job_id}/artifacts/keep") end |
#job_cancel(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Cancel a job
178 179 180 |
# File 'lib/gitlab/client/jobs.rb', line 178 def job_cancel(project_id, job_id) post("/projects/#{url_encode project_id}/jobs/#{job_id}/cancel") end |
#job_erase(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Erase Job
204 205 206 |
# File 'lib/gitlab/client/jobs.rb', line 204 def job_erase(project_id, job_id) post("/projects/#{url_encode project_id}/jobs/#{job_id}/erase") end |
#job_play(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Play a Job Triggers a manual action to start a job.
218 219 220 |
# File 'lib/gitlab/client/jobs.rb', line 218 def job_play(project_id, job_id) post("/projects/#{url_encode project_id}/jobs/#{job_id}/play") end |
#job_retry(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Retry a job
191 192 193 |
# File 'lib/gitlab/client/jobs.rb', line 191 def job_retry(project_id, job_id) post("/projects/#{url_encode project_id}/jobs/#{job_id}/retry") end |
#job_trace(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>
Get Job Trace
162 163 164 165 166 167 |
# File 'lib/gitlab/client/jobs.rb', line 162 def job_trace(project_id, job_id) get("/projects/#{url_encode project_id}/jobs/#{job_id}/trace", format: nil, headers: { Accept: 'text/plain' }, parser: ::Gitlab::Request::Parser) end |
#jobs(project_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Jobs for a Project
20 21 22 |
# File 'lib/gitlab/client/jobs.rb', line 20 def jobs(project_id, = {}) get("/projects/#{url_encode project_id}/jobs", query: ) end |
#pipeline_bridges(project_id, pipeline_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Bridge Jobs from a pipeline
50 51 52 |
# File 'lib/gitlab/client/jobs.rb', line 50 def pipeline_bridges(project_id, pipeline_id, = {}) get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/bridges", query: ) end |
#pipeline_jobs(project_id, pipeline_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>
Gets a list of Jobs from a pipeline
35 36 37 |
# File 'lib/gitlab/client/jobs.rb', line 35 def pipeline_jobs(project_id, pipeline_id, = {}) get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: ) end |