Class: Appetize::CI::GitLab

Inherits:
Object
  • Object
show all
Defined in:
lib/appetize/ci/gitlab.rb

Instance Method Summary collapse

Constructor Details

#initialize(project_id, ref_name, api_token, api_host = nil) ⇒ GitLab

Returns a new instance of GitLab.


8
9
10
11
12
13
# File 'lib/appetize/ci/gitlab.rb', line 8

def initialize(project_id, ref_name, api_token, api_host = nil)
  @project_id   = project_id
  @ref_name     = ref_name
  @api_token    = api_token
  @api_host     = api_host || "https://gitlab.com/api/v4"
end

Instance Method Details

#fetch_artifact(job, artifact_name) ⇒ Object


15
16
17
18
19
20
21
22
23
# File 'lib/appetize/ci/gitlab.rb', line 15

def fetch_artifact(job, artifact_name)
  url = "#{@api_host}/projects/#{@project_id}/jobs/artifacts/#{@ref_name}/raw/#{artifact_name}?job=#{job}"

  headers = {
    "PRIVATE-TOKEN" => @api_token
  }

  HTTParty.get(url, headers: headers)
end