Class: RoboPigeon::GitLab::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/robopigeon/gitlab/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.branchObject

Returns the value of attribute branch.



9
10
11
# File 'lib/robopigeon/gitlab/client.rb', line 9

def branch
  @branch
end

.enabledObject

Returns the value of attribute enabled.



9
10
11
# File 'lib/robopigeon/gitlab/client.rb', line 9

def enabled
  @enabled
end

.pipeline_idObject

Returns the value of attribute pipeline_id.



9
10
11
# File 'lib/robopigeon/gitlab/client.rb', line 9

def pipeline_id
  @pipeline_id
end

.projectObject

Returns the value of attribute project.



9
10
11
# File 'lib/robopigeon/gitlab/client.rb', line 9

def project
  @project
end

Class Method Details

.clientObject



10
11
12
# File 'lib/robopigeon/gitlab/client.rb', line 10

def client
  Gitlab.client
end

.create_tag(ref, tag, message) ⇒ Object



28
29
30
# File 'lib/robopigeon/gitlab/client.rb', line 28

def create_tag(ref, tag, message)
  client.create_tag(project, tag, ref, message)
end

.get_deployment(environment, page = 0) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/robopigeon/gitlab/client.rb', line 14

def get_deployment(environment, page = 0)
  deployments = client.deployments(
    project,
    order_by: 'created_at',
    sort: 'desc',
    per_page: 20,
    page: page
  )
  deployment = deployments.select { |dep| dep.environment.name == environment }.first
  return get_deployment(environment, page + 1) if deployment.nil? && deployments.has_next_page?

  deployment
end

.merge_request_comment(text, source = branch) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/robopigeon/gitlab/client.rb', line 32

def merge_request_comment(text, source = branch)
  merge_requests = client.merge_requests(project, source_branch: source)
  raise "No merge requests exist for branch '#{source}'" if merge_requests.empty?

  merge_requests.each do |merge_request|
    client.create_merge_request_discussion(project, merge_request.iid, body: text)
  end
end