Class: TerraspaceCiGitlab::Vars

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

Instance Method Summary collapse

Instance Method Details

#branch_nameObject



36
37
38
# File 'lib/terraspace_ci_gitlab/vars.rb', line 36

def branch_name
  ENV['CI_COMMIT_REF_NAME']
end

#dataObject

Interface method. Hash of properties to be stored



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/terraspace_ci_gitlab/vars.rb', line 4

def data
  {
    build_system: "gitlab",   # required
    host: host,
    full_repo: full_repo,
    branch_name: branch_name,
    # urls
    pr_url: pr_url,
    build_url: ENV['CI_PIPELINE_URL'],
    # additional properties
    build_type: ENV['CI_PIPELINE_SOURCE'], # IE: merge_request_event
    pr_number: pr_number,  # set when build_type=pull_request
    sha: sha,
    # additional properties
    commit_message: ENV['CI_COMMIT_MESSAGE'],
    build_id: ENV['CI_PIPELINE_ID'],
    build_number: ENV['CI_PIPELINE_IID'],
  }
end

#full_repoObject



44
45
46
# File 'lib/terraspace_ci_gitlab/vars.rb', line 44

def full_repo
  ENV['CI_PROJECT_PATH']
end

#hostObject



24
25
26
# File 'lib/terraspace_ci_gitlab/vars.rb', line 24

def host
  ENV['CI_SERVER_URL'] || 'https://gitlab.com'
end

#pr_numberObject



32
33
34
# File 'lib/terraspace_ci_gitlab/vars.rb', line 32

def pr_number
  ENV['CI_MERGE_REQUEST_IID']
end

#pr_urlObject



28
29
30
# File 'lib/terraspace_ci_gitlab/vars.rb', line 28

def pr_url
  "#{host}/#{full_repo}/-/merge_requests/#{pr_number}" if pr_number
end

#shaObject



40
41
42
# File 'lib/terraspace_ci_gitlab/vars.rb', line 40

def sha
  ENV['CI_COMMIT_SHA']
end