Class: GLPL

Inherits:
Object
  • Object
show all
Defined in:
lib/glpl.rb

Overview

— FUNCTIONS

Defined Under Namespace

Classes: Job, Pipeline

Instance Method Summary collapse

Constructor Details

#initialize(private_token) ⇒ GLPL

Creates a new GLPL instance with the provided Gitlab’s Private Token.

Params:

private_token

String Gitlab’s Private Token to be used when making requests to Gitlab’s API.



14
15
16
17
# File 'lib/glpl.rb', line 14

def initialize(private_token)
  @private_token = private_token
  @api_url = "https://gitlab.com/api/v4/projects"
end

Instance Method Details

#cancel(project_id, pipeline_id) ⇒ Object

Cancels a pipeline.

Params:

project_id

Integer Gitlab’s project ID.

pipeline_id

Integer The pipeline’s ID.



46
47
48
# File 'lib/glpl.rb', line 46

def cancel(project_id, pipeline_id)
  GLPL::Pipeline.new(request("/#{project_id}/pipelines/#{pipeline_id}/cancel", :post))
end

#jobs(project_id, pipeline_id) ⇒ Object

List jobs for a given project’s pipeline. Params:

project_id

Integer Gitlab’s project ID.

pipeline_id

Integer The pipeline’s ID.



29
30
31
# File 'lib/glpl.rb', line 29

def jobs(project_id, pipeline_id)
  request("/#{project_id}/pipelines/#{pipeline_id}/jobs", :get).map { |data| GLPL::Job.new(data) }
end

#pipelines(project_id) ⇒ Object

List recent pipelines for a given project. Params:

project_id

Integer which contains the Gitlab’s project id.



21
22
23
# File 'lib/glpl.rb', line 21

def pipelines(project_id)
  request("/#{project_id}/pipelines", :get).map { |data| GLPL::Pipeline.new(data) }
end

#retry(project_id, pipeline_id) ⇒ Object

Retries a pipeline. Params:

project_id

Integer Gitlab’s project ID.

pipeline_id

Integer The pipeline’s ID.



37
38
39
# File 'lib/glpl.rb', line 37

def retry(project_id, pipeline_id)
  GLPL::Pipeline.new(request("/#{project_id}/pipelines/#{pipeline_id}/retry", :post))
end