module Gitlab::Client::Pipelines

Defines methods related to pipelines. @see docs.gitlab.com/ce/api/pipelines.html

Public Instance Methods

cancel_pipeline(project, id) click to toggle source

Cancels a pipeline.

@example

Gitlab.cancel_pipeline(5, 1)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [Gitlab::ObjectifiedHash] The pipelines changes.

# File lib/gitlab/client/pipelines.rb, line 89
def cancel_pipeline(project, id)
  post("/projects/#{url_encode project}/pipelines/#{id}/cancel")
end
create_pipeline(project, ref, variables = {}) click to toggle source

Create a pipeline.

@example

Gitlab.create_pipeline(5, 'master')

@param [Integer, String] project The ID or name of a project. @param [String] ref Reference to commit. @param [Hash] variables Variables passed to pipelines @return [Gitlab::ObjectifiedHash] The pipelines changes.

# File lib/gitlab/client/pipelines.rb, line 67
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) click to toggle source

Delete a pipeline

@example

Gitlab.delete_pipeline(5, 1)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [void] This API call returns an empty response body.

# File lib/gitlab/client/pipelines.rb, line 113
def delete_pipeline(project, id)
  delete("/projects/#{url_encode project}/pipelines/#{id}")
end
pipeline(project, id) click to toggle source

Gets a single pipeline.

@example

Gitlab.pipeline(5, 36)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [Gitlab::ObjectifiedHash]

# 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) click to toggle source

Gets a single pipeline’s test report.

@example

Gitlab.pipeline_test_report(5, 36)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [Gitlab::ObjectifiedHash]

# File lib/gitlab/client/pipelines.rb, line 42
def pipeline_test_report(project, id)
  get("/projects/#{url_encode project}/pipelines/#{id}/test_report")
end
pipeline_variables(project, id) click to toggle source

Gets a single pipeline’s variables.

@example

Gitlab.pipeline_variables(5, 36)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [Array<Gitlab::ObjectifiedHash>]

# File lib/gitlab/client/pipelines.rb, line 54
def pipeline_variables(project, id)
  get("/projects/#{url_encode project}/pipelines/#{id}/variables")
end
pipelines(project, options = {}) click to toggle source

Gets a list of project pipelines.

@example

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

@param [Integer, String] project The ID or name of a project. @param [Hash] options A customizable set of options. @option options [Integer] :page The page number. @option options [Integer] :per_page The number of results per page. @return [Array<Gitlab::ObjectifiedHash>]

# 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) click to toggle source

Retry a pipeline.

@example

Gitlab.retry_pipeline(5, 1)

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @return [Array<Gitlab::ObjectifiedHash>] The pipelines changes.

# File lib/gitlab/client/pipelines.rb, line 101
def retry_pipeline(project, id)
  post("/projects/#{url_encode project}/pipelines/#{id}/retry")
end
update_pipeline_metadata(project, id, options = {}) click to toggle source

Update a pipeline metadata

@example

Gitlab.update_pipeline_metadata(5, 1, name: 'new name')

@param [Integer, String] project The ID or name of a project. @param [Integer] id The ID of a pipeline. @option options [String] :name The new name of the pipeline. @return [Gitlab::ObjectifiedHash]

# File lib/gitlab/client/pipelines.rb, line 126
def update_pipeline_metadata(project, id, options = {})
  put("/projects/#{url_encode project}/pipelines/#{id}/metadata", body: options)
end