Module: Gitlab::Client::Pipelines

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/pipelines.rb

Overview

Defines methods related to pipelines.

Instance Method Summary collapse

Instance Method Details

#cancel_pipeline(project, id) ⇒ Gitlab::ObjectifiedHash

Cancels a pipeline.

Examples:

Gitlab.cancel_pipeline(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a pipeline.

Returns:


77
78
79
# File 'lib/gitlab/client/pipelines.rb', line 77

def cancel_pipeline(project, id)
  post("/projects/#{url_encode project}/pipelines/#{id}/cancel")
end

#create_pipeline(project, ref, variables = {}) ⇒ Gitlab::ObjectifiedHash

Create a pipeline.

Examples:

Gitlab.create_pipeline(5, 'master')

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • ref (String)

    Reference to commit.

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

    Variables passed to pipelines

Returns:


55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/gitlab/client/pipelines.rb', line 55

def create_pipeline(project, ref, variables = {})
  body = {}

  # This mapping is necessary, cause the API expects an array with objects (with `key` and `value` keys)
  # See: https://docs.gitlab.com/ee/api/pipelines.html#create-a-new-pipeline
  body[:variables] = variables.map { |(key, value)| { key: key, value: value } } if variables.any?

  post(
    "/projects/#{url_encode project}/pipeline",
    query: { ref: ref },
    body: body
  )
end

#delete_pipeline(project, id) ⇒ void

This method returns an undefined value.

Delete a pipeline

Examples:

Gitlab.delete_pipeline(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a pipeline.


101
102
103
# File 'lib/gitlab/client/pipelines.rb', line 101

def delete_pipeline(project, id)
  delete("/projects/#{url_encode project}/pipelines/#{id}")
end

#pipeline(project, id) ⇒ Gitlab::ObjectifiedHash

Gets a single pipeline.

Examples:

Gitlab.pipeline(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a pipeline.

Returns:


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

def pipeline(project, id)
  get("/projects/#{url_encode project}/pipelines/#{id}")
end

#pipeline_test_report(project, id) ⇒ Gitlab::ObjectifiedHash

Gets a single pipeline's test report.

Examples:

Gitlab.pipeline_test_report(5, 36)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a pipeline.

Returns:


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

def pipeline_test_report(project, id)
  get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
end

#pipelines(project, options = {}) ⇒ Array<Gitlab::ObjectifiedHash>

Gets a list of project pipelines.

Examples:

Gitlab.pipelines(5)
Gitlab.pipelines(5, { per_page: 10, page:  2 })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

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

    A customizable set of options.

Options Hash (options):

  • :page (Integer)

    The page number.

  • :per_page (Integer)

    The number of results per page.

Returns:


18
19
20
# File 'lib/gitlab/client/pipelines.rb', line 18

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

#retry_pipeline(project, id) ⇒ Array<Gitlab::ObjectifiedHash>

Retry a pipeline.

Examples:

Gitlab.retry_pipeline(5, 1)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • id (Integer)

    The ID of a pipeline.

Returns:


89
90
91
# File 'lib/gitlab/client/pipelines.rb', line 89

def retry_pipeline(project, id)
  post("/projects/#{url_encode project}/pipelines/#{id}/retry")
end