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

Instance Method Details

#job(project_id, job_id) ⇒ Object

Gets a single job

Examples:

Gitlab.job(1, 2)
Gitlab.job("project", 2)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job


42
43
44
# File 'lib/gitlab/client/jobs.rb', line 42

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

Examples:

Gitlab.job_artifacts(1, 2)
Gitlab.job_artifacts("project", 2)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


55
56
57
58
59
60
# File 'lib/gitlab/client/jobs.rb', line 55

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_download(project_id, ref_name, job_name) ⇒ Array<Gitlab::ObjectifiedHash>

Download Job Artifact

Examples:

Gitlab.job_artifacts_download(1, "master", "release")
Gitlab.job_artifacts_download("project", "master", "release")

Parameters:

  • id, (Integer, String)

    The ID or name of a project.

  • ref, (String)

    Ref Name

  • job, (String)

    jobname

Returns:


72
73
74
75
76
77
# File 'lib/gitlab/client/jobs.rb', line 72

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: 'text/plain' },
                                                                                parser: ::Gitlab::Request::Parser)
end

#job_artifacts_keep(project_id, job_id) ⇒ Array<Gitlab::ObjectifiedHash>

Keep Artifacts Prevents artifacts from being deleted when expiration is set.

Examples:

Gitlab.job_artifacts_keep(1,1)
Gitlab.job_artifacts_keep("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


158
159
160
# File 'lib/gitlab/client/jobs.rb', line 158

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

Examples:

Gitlab.job_cancel(1,1)
Gitlab.job_cancel("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


104
105
106
# File 'lib/gitlab/client/jobs.rb', line 104

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

Examples:

Gitlab.job_erase(1,1)
Gitlab.job_erase("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


130
131
132
# File 'lib/gitlab/client/jobs.rb', line 130

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.

Examples:

Gitlab.job_play(1,1)
Gitlab.job_play("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


144
145
146
# File 'lib/gitlab/client/jobs.rb', line 144

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

Examples:

Gitlab.job_retry(1,1)
Gitlab.job_retry("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


117
118
119
# File 'lib/gitlab/client/jobs.rb', line 117

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

Examples:

Gitlab.job_trace(1,1)
Gitlab.job_trace("project", 1)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the job

Returns:


88
89
90
91
92
93
# File 'lib/gitlab/client/jobs.rb', line 88

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

Examples:

Gitlab.jobs(1)
Gitlab.jobs("project")

Parameters:

  • id (Integer, String)

    The ID or name of a project.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :scope (Array)

    The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.

Returns:


15
16
17
# File 'lib/gitlab/client/jobs.rb', line 15

def jobs(project_id, options = {})
  get("/projects/#{url_encode project_id}/jobs", query: options)
end

#pipeline_jobs(project_id, pipeline_id, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of Jobs from a pipeline

Examples:

Gitlab.pipeline_jobs(1, 2)
Gitlab.pipeline_jobs("project", 2)

Parameters:

  • The (Integer, String)

    ID or name of a project.

  • the (Integer)

    id of the pipeline

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :scope (Array)

    The scope of jobs to show, one or array of: created, pending, running, failed, success, canceled, skipped, manual; showing all jobs if none provided.

Returns:


30
31
32
# File 'lib/gitlab/client/jobs.rb', line 30

def pipeline_jobs(project_id, pipeline_id, options = {})
  get("/projects/#{url_encode project_id}/pipelines/#{pipeline_id}/jobs", query: options)
end