Class: Datadog::CI::Ext::Environment::Providers::Gitlab

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/ci/ext/environment/providers/gitlab.rb

Overview

Instance Attribute Summary

Attributes inherited from Base

#env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#additional_tags, #git_branch_or_tag, #git_commit_committer_date, #git_commit_committer_email, #git_commit_committer_name, #initialize

Constructor Details

This class inherits a constructor from Datadog::CI::Ext::Environment::Providers::Base

Class Method Details

.handles?(env) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 13

def self.handles?(env)
  env.key?("GITLAB_CI")
end

Instance Method Details

#ci_env_varsObject



95
96
97
98
99
100
101
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 95

def ci_env_vars
  {
    "CI_PROJECT_URL" => env["CI_PROJECT_URL"],
    "CI_PIPELINE_ID" => env["CI_PIPELINE_ID"],
    "CI_JOB_ID" => env["CI_JOB_ID"]
  }.to_json
end

#git_branchObject



69
70
71
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 69

def git_branch
  env["CI_COMMIT_REF_NAME"]
end

#git_commit_author_dateObject



87
88
89
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 87

def git_commit_author_date
  env["CI_COMMIT_TIMESTAMP"]
end

#git_commit_author_emailObject



82
83
84
85
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 82

def git_commit_author_email
  _name, email = extract_name_email
  email
end

#git_commit_author_nameObject



77
78
79
80
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 77

def git_commit_author_name
  name,  = extract_name_email
  name
end

#git_commit_messageObject



91
92
93
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 91

def git_commit_message
  env["CI_COMMIT_MESSAGE"]
end

#git_commit_shaObject



65
66
67
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 65

def git_commit_sha
  env["CI_COMMIT_SHA"]
end

#git_repository_urlObject



61
62
63
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 61

def git_repository_url
  env["CI_REPOSITORY_URL"]
end

#git_tagObject



73
74
75
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 73

def git_tag
  env["CI_COMMIT_TAG"]
end

#job_nameObject



21
22
23
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 21

def job_name
  env["CI_JOB_NAME"]
end

#job_urlObject



25
26
27
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 25

def job_url
  env["CI_JOB_URL"]
end

#node_labelsObject



57
58
59
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 57

def node_labels
  env["CI_RUNNER_TAGS"]
end

#node_nameObject



53
54
55
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 53

def node_name
  env["CI_RUNNER_ID"]
end

#pipeline_idObject



29
30
31
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 29

def pipeline_id
  env["CI_PIPELINE_ID"]
end

#pipeline_nameObject



33
34
35
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 33

def pipeline_name
  env["CI_PROJECT_PATH"]
end

#pipeline_numberObject



37
38
39
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 37

def pipeline_number
  env["CI_PIPELINE_IID"]
end

#pipeline_urlObject



41
42
43
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 41

def pipeline_url
  env["CI_PIPELINE_URL"]
end

#provider_nameObject



17
18
19
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 17

def provider_name
  Provider::GITLAB
end

#stage_nameObject



45
46
47
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 45

def stage_name
  env["CI_JOB_STAGE"]
end

#workspace_pathObject



49
50
51
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 49

def workspace_path
  env["CI_PROJECT_DIR"]
end