Class: Datadog::CI::Ext::Environment::Providers::LocalGit
- Inherits:
-
Base
- Object
- Base
- Datadog::CI::Ext::Environment::Providers::LocalGit
show all
- Defined in:
- lib/datadog/ci/ext/environment/providers/local_git.rb
Overview
As a fallback we try to fetch git information from the local git repository
Defined Under Namespace
Classes: GitUser, NilUser
Instance Attribute Summary
Attributes inherited from Base
#env
Instance Method Summary
collapse
Methods inherited from Base
#ci_env_vars, #git_branch_or_tag, #initialize, #job_name, #job_url, #node_labels, #node_name, #pipeline_id, #pipeline_name, #pipeline_number, #pipeline_url, #provider_name, #stage_name
Instance Method Details
#git_branch ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 33
def git_branch
exec_git_command("git rev-parse --abbrev-ref HEAD")
rescue => e
Datadog.logger.debug(
"Unable to read git branch: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|
#git_commit_author_date ⇒ Object
68
69
70
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 68
def git_commit_author_date
author.date
end
|
#git_commit_author_email ⇒ Object
64
65
66
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 64
def git_commit_author_email
author.email
end
|
#git_commit_author_name ⇒ Object
60
61
62
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 60
def git_commit_author_name
author.name
end
|
#git_commit_committer_date ⇒ Object
80
81
82
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 80
def git_commit_committer_date
committer.date
end
|
#git_commit_committer_email ⇒ Object
76
77
78
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 76
def git_commit_committer_email
committer.email
end
|
#git_commit_committer_name ⇒ Object
72
73
74
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 72
def git_commit_committer_name
committer.name
end
|
#git_commit_message ⇒ Object
51
52
53
54
55
56
57
58
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 51
def git_commit_message
exec_git_command("git show -s --format=%s")
rescue => e
Datadog.logger.debug(
"Unable to read git commit message: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|
#git_commit_sha ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 24
def git_commit_sha
exec_git_command("git rev-parse HEAD")
rescue => e
Datadog.logger.debug(
"Unable to read git commit SHA: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|
#git_repository_url ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 15
def git_repository_url
exec_git_command("git ls-remote --get-url")
rescue => e
Datadog.logger.debug(
"Unable to read git repository url: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|
#git_tag ⇒ Object
42
43
44
45
46
47
48
49
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 42
def git_tag
exec_git_command("git tag --points-at HEAD")
rescue => e
Datadog.logger.debug(
"Unable to read git tag: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|
#workspace_path ⇒ Object
84
85
86
87
88
89
90
91
|
# File 'lib/datadog/ci/ext/environment/providers/local_git.rb', line 84
def workspace_path
exec_git_command("git rev-parse --show-toplevel")
rescue => e
Datadog.logger.debug(
"Unable to read git base directory: #{e.class.name} #{e.message} at #{Array(e.backtrace).first}"
)
nil
end
|