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

#git_branch_or_tag, #git_commit_committer_date, #git_commit_committer_email, #git_commit_committer_name, #git_commit_head_author_date, #git_commit_head_author_email, #git_commit_head_author_name, #git_commit_head_committer_date, #git_commit_head_committer_email, #git_commit_head_committer_name, #git_commit_head_message, #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



99
100
101
102
103
104
105
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 99

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



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

def git_branch
  env["CI_COMMIT_REF_NAME"]
end

#git_commit_author_dateObject



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

def git_commit_author_date
  env["CI_COMMIT_TIMESTAMP"]
end

#git_commit_author_emailObject



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

def git_commit_author_email
  _name, email = extract_name_email
  email
end

#git_commit_author_nameObject



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

def git_commit_author_name
  name,  = extract_name_email
  name
end

#git_commit_head_shaObject



119
120
121
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 119

def git_commit_head_sha
  env["CI_MERGE_REQUEST_SOURCE_BRANCH_SHA"]
end

#git_commit_messageObject



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

def git_commit_message
  env["CI_COMMIT_MESSAGE"]
end

#git_commit_shaObject



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

def git_commit_sha
  env["CI_COMMIT_SHA"]
end

#git_pull_request_base_branchObject



107
108
109
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 107

def git_pull_request_base_branch
  env["CI_MERGE_REQUEST_TARGET_BRANCH_NAME"]
end

#git_pull_request_base_branch_head_shaObject



115
116
117
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 115

def git_pull_request_base_branch_head_sha
  env["CI_MERGE_REQUEST_TARGET_BRANCH_SHA"]
end

#git_pull_request_base_branch_shaObject



111
112
113
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 111

def git_pull_request_base_branch_sha
  env["CI_MERGE_REQUEST_DIFF_BASE_SHA"]
end

#git_repository_urlObject



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

def git_repository_url
  env["CI_REPOSITORY_URL"]
end

#git_tagObject



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

def git_tag
  env["CI_COMMIT_TAG"]
end

#job_idObject



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

def job_id
  env["CI_JOB_ID"]
end

#job_nameObject



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

def job_name
  env["CI_JOB_NAME"]
end

#job_urlObject



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

def job_url
  env["CI_JOB_URL"]
end

#node_labelsObject



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

def node_labels
  env["CI_RUNNER_TAGS"]
end

#node_nameObject



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

def node_name
  env["CI_RUNNER_ID"]
end

#pipeline_idObject



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

def pipeline_id
  env["CI_PIPELINE_ID"]
end

#pipeline_nameObject



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

def pipeline_name
  env["CI_PROJECT_PATH"]
end

#pipeline_numberObject



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

def pipeline_number
  env["CI_PIPELINE_IID"]
end

#pipeline_urlObject



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

def pipeline_url
  env["CI_PIPELINE_URL"]
end

#pr_numberObject



123
124
125
# File 'lib/datadog/ci/ext/environment/providers/gitlab.rb', line 123

def pr_number
  env["CI_MERGE_REQUEST_IID"]
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



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

def stage_name
  env["CI_JOB_STAGE"]
end

#workspace_pathObject



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

def workspace_path
  env["CI_PROJECT_DIR"]
end