datadog-ci 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +30 -0
- data/LICENSE +6 -0
- data/LICENSE-3rdparty.csv +2 -0
- data/LICENSE.Apache +200 -0
- data/LICENSE.BSD3 +24 -0
- data/NOTICE +4 -0
- data/README.md +125 -0
- data/lib/datadog/ci/configuration/components.rb +32 -0
- data/lib/datadog/ci/configuration/settings.rb +51 -0
- data/lib/datadog/ci/contrib/cucumber/configuration/settings.rb +36 -0
- data/lib/datadog/ci/contrib/cucumber/ext.rb +22 -0
- data/lib/datadog/ci/contrib/cucumber/formatter.rb +94 -0
- data/lib/datadog/ci/contrib/cucumber/instrumentation.rb +28 -0
- data/lib/datadog/ci/contrib/cucumber/integration.rb +47 -0
- data/lib/datadog/ci/contrib/cucumber/patcher.rb +27 -0
- data/lib/datadog/ci/contrib/minitest/configuration/settings.rb +36 -0
- data/lib/datadog/ci/contrib/minitest/ext.rb +21 -0
- data/lib/datadog/ci/contrib/minitest/hooks.rb +66 -0
- data/lib/datadog/ci/contrib/minitest/integration.rb +46 -0
- data/lib/datadog/ci/contrib/minitest/patcher.rb +26 -0
- data/lib/datadog/ci/contrib/rspec/configuration/settings.rb +36 -0
- data/lib/datadog/ci/contrib/rspec/example.rb +70 -0
- data/lib/datadog/ci/contrib/rspec/ext.rb +21 -0
- data/lib/datadog/ci/contrib/rspec/integration.rb +50 -0
- data/lib/datadog/ci/contrib/rspec/patcher.rb +27 -0
- data/lib/datadog/ci/ext/app_types.rb +11 -0
- data/lib/datadog/ci/ext/environment/extractor.rb +101 -0
- data/lib/datadog/ci/ext/environment/providers/appveyor.rb +98 -0
- data/lib/datadog/ci/ext/environment/providers/azure.rb +109 -0
- data/lib/datadog/ci/ext/environment/providers/base.rb +115 -0
- data/lib/datadog/ci/ext/environment/providers/bitbucket.rb +69 -0
- data/lib/datadog/ci/ext/environment/providers/bitrise.rb +77 -0
- data/lib/datadog/ci/ext/environment/providers/buddy.rb +69 -0
- data/lib/datadog/ci/ext/environment/providers/buildkite.rb +95 -0
- data/lib/datadog/ci/ext/environment/providers/circleci.rb +82 -0
- data/lib/datadog/ci/ext/environment/providers/codefresh.rb +49 -0
- data/lib/datadog/ci/ext/environment/providers/github_actions.rb +76 -0
- data/lib/datadog/ci/ext/environment/providers/gitlab.rb +119 -0
- data/lib/datadog/ci/ext/environment/providers/jenkins.rb +74 -0
- data/lib/datadog/ci/ext/environment/providers/local_git.rb +170 -0
- data/lib/datadog/ci/ext/environment/providers/teamcity.rb +29 -0
- data/lib/datadog/ci/ext/environment/providers/travis.rb +65 -0
- data/lib/datadog/ci/ext/environment/providers/user_defined_tags.rb +62 -0
- data/lib/datadog/ci/ext/environment/providers.rb +52 -0
- data/lib/datadog/ci/ext/environment.rb +82 -0
- data/lib/datadog/ci/ext/git.rb +37 -0
- data/lib/datadog/ci/ext/settings.rb +12 -0
- data/lib/datadog/ci/ext/test.rb +37 -0
- data/lib/datadog/ci/extensions.rb +19 -0
- data/lib/datadog/ci/flush.rb +38 -0
- data/lib/datadog/ci/test.rb +82 -0
- data/lib/datadog/ci/utils/git.rb +22 -0
- data/lib/datadog/ci/version.rb +28 -0
- data/lib/datadog/ci.rb +24 -0
- data/sig/datadog/ci/configuration/components.rbs +11 -0
- data/sig/datadog/ci/configuration/settings.rbs +14 -0
- data/sig/datadog/ci/contrib/cucumber/configuration/settings.rbs +12 -0
- data/sig/datadog/ci/contrib/cucumber/ext.rbs +25 -0
- data/sig/datadog/ci/contrib/cucumber/formatter.rbs +35 -0
- data/sig/datadog/ci/contrib/cucumber/instrumentation.rbs +16 -0
- data/sig/datadog/ci/contrib/cucumber/integration.rbs +25 -0
- data/sig/datadog/ci/contrib/cucumber/patcher.rbs +15 -0
- data/sig/datadog/ci/contrib/minitest/configuration/settings.rbs +12 -0
- data/sig/datadog/ci/contrib/minitest/ext.rbs +23 -0
- data/sig/datadog/ci/contrib/minitest/hooks.rbs +19 -0
- data/sig/datadog/ci/contrib/minitest/integration.rbs +25 -0
- data/sig/datadog/ci/contrib/minitest/patcher.rbs +15 -0
- data/sig/datadog/ci/contrib/rspec/configuration/settings.rbs +12 -0
- data/sig/datadog/ci/contrib/rspec/example.rbs +20 -0
- data/sig/datadog/ci/contrib/rspec/ext.rbs +23 -0
- data/sig/datadog/ci/contrib/rspec/integration.rbs +25 -0
- data/sig/datadog/ci/contrib/rspec/patcher.rbs +15 -0
- data/sig/datadog/ci/ext/app_types.rbs +9 -0
- data/sig/datadog/ci/ext/environment/extractor.rbs +27 -0
- data/sig/datadog/ci/ext/environment/providers/appveyor.rbs +48 -0
- data/sig/datadog/ci/ext/environment/providers/azure.rbs +56 -0
- data/sig/datadog/ci/ext/environment/providers/base.rbs +69 -0
- data/sig/datadog/ci/ext/environment/providers/bitbucket.rbs +37 -0
- data/sig/datadog/ci/ext/environment/providers/bitrise.rbs +41 -0
- data/sig/datadog/ci/ext/environment/providers/buddy.rbs +37 -0
- data/sig/datadog/ci/ext/environment/providers/buildkite.rbs +45 -0
- data/sig/datadog/ci/ext/environment/providers/circleci.rbs +41 -0
- data/sig/datadog/ci/ext/environment/providers/codefresh.rbs +25 -0
- data/sig/datadog/ci/ext/environment/providers/github_actions.rbs +37 -0
- data/sig/datadog/ci/ext/environment/providers/gitlab.rbs +57 -0
- data/sig/datadog/ci/ext/environment/providers/jenkins.rbs +35 -0
- data/sig/datadog/ci/ext/environment/providers/local_git.rbs +66 -0
- data/sig/datadog/ci/ext/environment/providers/teamcity.rbs +17 -0
- data/sig/datadog/ci/ext/environment/providers/travis.rbs +35 -0
- data/sig/datadog/ci/ext/environment/providers/user_defined_tags.rbs +33 -0
- data/sig/datadog/ci/ext/environment/providers.rbs +13 -0
- data/sig/datadog/ci/ext/environment.rbs +44 -0
- data/sig/datadog/ci/ext/git.rbs +53 -0
- data/sig/datadog/ci/ext/settings.rbs +9 -0
- data/sig/datadog/ci/ext/test.rbs +43 -0
- data/sig/datadog/ci/extensions.rbs +7 -0
- data/sig/datadog/ci/flush.rbs +15 -0
- data/sig/datadog/ci/test.rbs +18 -0
- data/sig/datadog/ci/utils/git.rbs +11 -0
- data/sig/datadog/ci/version.rbs +16 -0
- data/sig/datadog/ci.rbs +7 -0
- metadata +154 -0
@@ -0,0 +1,109 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Ext
|
10
|
+
module Environment
|
11
|
+
module Providers
|
12
|
+
# Azure Pipelines: https://azure.microsoft.com/en-us/products/devops/pipelines
|
13
|
+
# Environment variables docs: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml
|
14
|
+
class Azure < Base
|
15
|
+
def provider_name
|
16
|
+
"azurepipelines"
|
17
|
+
end
|
18
|
+
|
19
|
+
def pipeline_url
|
20
|
+
return unless url_defined?
|
21
|
+
|
22
|
+
@pipeline_url ||= "#{team_foundation_server_uri}#{team_project_id}/_build/results?buildId=#{build_id}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def job_url
|
26
|
+
return unless url_defined?
|
27
|
+
|
28
|
+
@job_url ||= "#{pipeline_url}&view=logs&j=#{env["SYSTEM_JOBID"]}&t=#{env["SYSTEM_TASKINSTANCEID"]}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def workspace_path
|
32
|
+
env["BUILD_SOURCESDIRECTORY"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def pipeline_id
|
36
|
+
build_id
|
37
|
+
end
|
38
|
+
|
39
|
+
def pipeline_number
|
40
|
+
build_id
|
41
|
+
end
|
42
|
+
|
43
|
+
def pipeline_name
|
44
|
+
env["BUILD_DEFINITIONNAME"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def stage_name
|
48
|
+
env["SYSTEM_STAGEDISPLAYNAME"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def job_name
|
52
|
+
env["SYSTEM_JOBDISPLAYNAME"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def git_repository_url
|
56
|
+
env["SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI"] || env["BUILD_REPOSITORY_URI"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def git_commit_sha
|
60
|
+
env["SYSTEM_PULLREQUEST_SOURCECOMMITID"] || env["BUILD_SOURCEVERSION"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def git_branch_or_tag
|
64
|
+
env["SYSTEM_PULLREQUEST_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCHNAME"]
|
65
|
+
end
|
66
|
+
|
67
|
+
def git_commit_author_name
|
68
|
+
env["BUILD_REQUESTEDFORID"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_commit_author_email
|
72
|
+
env["BUILD_REQUESTEDFOREMAIL"]
|
73
|
+
end
|
74
|
+
|
75
|
+
def git_commit_message
|
76
|
+
env["BUILD_SOURCEVERSIONMESSAGE"]
|
77
|
+
end
|
78
|
+
|
79
|
+
def ci_env_vars
|
80
|
+
{
|
81
|
+
"SYSTEM_TEAMPROJECTID" => env["SYSTEM_TEAMPROJECTID"],
|
82
|
+
"BUILD_BUILDID" => env["BUILD_BUILDID"],
|
83
|
+
"SYSTEM_JOBID" => env["SYSTEM_JOBID"]
|
84
|
+
}.to_json
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
|
89
|
+
def build_id
|
90
|
+
env["BUILD_BUILDID"]
|
91
|
+
end
|
92
|
+
|
93
|
+
def team_foundation_server_uri
|
94
|
+
env["SYSTEM_TEAMFOUNDATIONSERVERURI"]
|
95
|
+
end
|
96
|
+
|
97
|
+
def team_project_id
|
98
|
+
env["SYSTEM_TEAMPROJECTID"]
|
99
|
+
end
|
100
|
+
|
101
|
+
def url_defined?
|
102
|
+
!(build_id && team_foundation_server_uri && team_project_id).nil?
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Datadog
|
4
|
+
module CI
|
5
|
+
module Ext
|
6
|
+
module Environment
|
7
|
+
module Providers
|
8
|
+
class Base
|
9
|
+
attr_reader :env
|
10
|
+
|
11
|
+
def initialize(env)
|
12
|
+
@env = env
|
13
|
+
end
|
14
|
+
|
15
|
+
def job_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def job_url
|
19
|
+
end
|
20
|
+
|
21
|
+
def pipeline_id
|
22
|
+
end
|
23
|
+
|
24
|
+
def pipeline_name
|
25
|
+
end
|
26
|
+
|
27
|
+
def pipeline_number
|
28
|
+
end
|
29
|
+
|
30
|
+
def pipeline_url
|
31
|
+
end
|
32
|
+
|
33
|
+
def provider_name
|
34
|
+
end
|
35
|
+
|
36
|
+
def stage_name
|
37
|
+
end
|
38
|
+
|
39
|
+
def workspace_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def node_labels
|
43
|
+
end
|
44
|
+
|
45
|
+
def node_name
|
46
|
+
end
|
47
|
+
|
48
|
+
def ci_env_vars
|
49
|
+
end
|
50
|
+
|
51
|
+
def git_branch
|
52
|
+
return @branch if defined?(@branch)
|
53
|
+
|
54
|
+
set_branch_and_tag
|
55
|
+
@branch
|
56
|
+
end
|
57
|
+
|
58
|
+
def git_repository_url
|
59
|
+
end
|
60
|
+
|
61
|
+
def git_tag
|
62
|
+
return @tag if defined?(@tag)
|
63
|
+
|
64
|
+
set_branch_and_tag
|
65
|
+
@tag
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_branch_or_tag
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_commit_author_date
|
72
|
+
end
|
73
|
+
|
74
|
+
def git_commit_author_email
|
75
|
+
end
|
76
|
+
|
77
|
+
def git_commit_author_name
|
78
|
+
end
|
79
|
+
|
80
|
+
def git_commit_committer_date
|
81
|
+
end
|
82
|
+
|
83
|
+
def git_commit_committer_email
|
84
|
+
end
|
85
|
+
|
86
|
+
def git_commit_committer_name
|
87
|
+
end
|
88
|
+
|
89
|
+
def git_commit_message
|
90
|
+
end
|
91
|
+
|
92
|
+
def git_commit_sha
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
|
97
|
+
def set_branch_and_tag
|
98
|
+
branch_or_tag_string = git_branch_or_tag
|
99
|
+
@branch = @tag = nil
|
100
|
+
|
101
|
+
# @type var branch_or_tag_string: untyped
|
102
|
+
if branch_or_tag_string && branch_or_tag_string.include?("tags/")
|
103
|
+
@tag = branch_or_tag_string
|
104
|
+
else
|
105
|
+
@branch = branch_or_tag_string
|
106
|
+
end
|
107
|
+
|
108
|
+
[@branch, @tag]
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Ext
|
8
|
+
module Environment
|
9
|
+
module Providers
|
10
|
+
# Bitbucket Pipelines: https://bitbucket.org/product/features/pipelines
|
11
|
+
# Environment variables docs: https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/
|
12
|
+
class Bitbucket < Base
|
13
|
+
# overridden methods
|
14
|
+
def provider_name
|
15
|
+
"bitbucket"
|
16
|
+
end
|
17
|
+
|
18
|
+
def pipeline_id
|
19
|
+
env["BITBUCKET_PIPELINE_UUID"] ? env["BITBUCKET_PIPELINE_UUID"].tr("{}", "") : nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def pipeline_name
|
23
|
+
env["BITBUCKET_REPO_FULL_NAME"]
|
24
|
+
end
|
25
|
+
|
26
|
+
def pipeline_number
|
27
|
+
env["BITBUCKET_BUILD_NUMBER"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def pipeline_url
|
31
|
+
url
|
32
|
+
end
|
33
|
+
|
34
|
+
def job_url
|
35
|
+
url
|
36
|
+
end
|
37
|
+
|
38
|
+
def workspace_path
|
39
|
+
env["BITBUCKET_CLONE_DIR"]
|
40
|
+
end
|
41
|
+
|
42
|
+
def git_repository_url
|
43
|
+
env["BITBUCKET_GIT_SSH_ORIGIN"] || env["BITBUCKET_GIT_HTTP_ORIGIN"]
|
44
|
+
end
|
45
|
+
|
46
|
+
def git_commit_sha
|
47
|
+
env["BITBUCKET_COMMIT"]
|
48
|
+
end
|
49
|
+
|
50
|
+
def git_branch
|
51
|
+
env["BITBUCKET_BRANCH"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def git_tag
|
55
|
+
env["BITBUCKET_TAG"]
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def url
|
61
|
+
"https://bitbucket.org/#{env["BITBUCKET_REPO_FULL_NAME"]}/addon/pipelines/home#" \
|
62
|
+
"!/results/#{env["BITBUCKET_BUILD_NUMBER"]}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Ext
|
8
|
+
module Environment
|
9
|
+
module Providers
|
10
|
+
# Bitrise: https://bitrise.io/
|
11
|
+
# Environment variables docs: https://devcenter.bitrise.io/en/references/available-environment-variables.html
|
12
|
+
class Bitrise < Base
|
13
|
+
def provider_name
|
14
|
+
"bitrise"
|
15
|
+
end
|
16
|
+
|
17
|
+
def pipeline_id
|
18
|
+
env["BITRISE_BUILD_SLUG"]
|
19
|
+
end
|
20
|
+
|
21
|
+
def pipeline_name
|
22
|
+
env["BITRISE_TRIGGERED_WORKFLOW_ID"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def pipeline_number
|
26
|
+
env["BITRISE_BUILD_NUMBER"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def pipeline_url
|
30
|
+
env["BITRISE_BUILD_URL"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def workspace_path
|
34
|
+
env["BITRISE_SOURCE_DIR"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_repository_url
|
38
|
+
env["GIT_REPOSITORY_URL"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def git_commit_sha
|
42
|
+
env["BITRISE_GIT_COMMIT"] || env["GIT_CLONE_COMMIT_HASH"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def git_branch
|
46
|
+
env["BITRISEIO_GIT_BRANCH_DEST"] || env["BITRISE_GIT_BRANCH"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def git_tag
|
50
|
+
env["BITRISE_GIT_TAG"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def git_commit_message
|
54
|
+
env["BITRISE_GIT_MESSAGE"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def git_commit_author_name
|
58
|
+
env["GIT_CLONE_COMMIT_AUTHOR_NAME"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def git_commit_author_email
|
62
|
+
env["GIT_CLONE_COMMIT_AUTHOR_EMAIL"]
|
63
|
+
end
|
64
|
+
|
65
|
+
def git_commit_committer_name
|
66
|
+
env["GIT_CLONE_COMMIT_COMMITER_NAME"]
|
67
|
+
end
|
68
|
+
|
69
|
+
def git_commit_committer_email
|
70
|
+
env["GIT_CLONE_COMMIT_COMMITER_EMAIL"] || env["GIT_CLONE_COMMIT_COMMITER_NAME"]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
|
5
|
+
module Datadog
|
6
|
+
module CI
|
7
|
+
module Ext
|
8
|
+
module Environment
|
9
|
+
module Providers
|
10
|
+
# Buddy: https://buddy.works/
|
11
|
+
# Environment variables docs: https://buddy.works/docs/pipelines/environment-variables
|
12
|
+
class Buddy < Base
|
13
|
+
def provider_name
|
14
|
+
"buddy"
|
15
|
+
end
|
16
|
+
|
17
|
+
def pipeline_id
|
18
|
+
"#{env["BUDDY_PIPELINE_ID"]}/#{env["BUDDY_EXECUTION_ID"]}"
|
19
|
+
end
|
20
|
+
|
21
|
+
def pipeline_name
|
22
|
+
env["BUDDY_PIPELINE_NAME"]
|
23
|
+
end
|
24
|
+
|
25
|
+
def pipeline_number
|
26
|
+
env["BUDDY_EXECUTION_ID"]
|
27
|
+
end
|
28
|
+
|
29
|
+
def pipeline_url
|
30
|
+
env["BUDDY_EXECUTION_URL"]
|
31
|
+
end
|
32
|
+
|
33
|
+
def workspace_path
|
34
|
+
env["CI_WORKSPACE_PATH"]
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_repository_url
|
38
|
+
env["BUDDY_SCM_URL"]
|
39
|
+
end
|
40
|
+
|
41
|
+
def git_commit_sha
|
42
|
+
env["BUDDY_EXECUTION_REVISION"]
|
43
|
+
end
|
44
|
+
|
45
|
+
def git_branch
|
46
|
+
env["BUDDY_EXECUTION_BRANCH"]
|
47
|
+
end
|
48
|
+
|
49
|
+
def git_tag
|
50
|
+
env["BUDDY_EXECUTION_TAG"]
|
51
|
+
end
|
52
|
+
|
53
|
+
def git_commit_message
|
54
|
+
env["BUDDY_EXECUTION_REVISION_MESSAGE"]
|
55
|
+
end
|
56
|
+
|
57
|
+
def git_commit_committer_name
|
58
|
+
env["BUDDY_EXECUTION_REVISION_COMMITTER_NAME"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def git_commit_committer_email
|
62
|
+
env["BUDDY_EXECUTION_REVISION_COMMITTER_EMAIL"]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Ext
|
10
|
+
module Environment
|
11
|
+
module Providers
|
12
|
+
# Buildkite: https://buildkite.com/
|
13
|
+
# Environment variables docs: https://buildkite.com/docs/pipelines/environment-variables
|
14
|
+
class Buildkite < Base
|
15
|
+
def provider_name
|
16
|
+
"buildkite"
|
17
|
+
end
|
18
|
+
|
19
|
+
def job_url
|
20
|
+
"#{env["BUILDKITE_BUILD_URL"]}##{env["BUILDKITE_JOB_ID"]}"
|
21
|
+
end
|
22
|
+
|
23
|
+
def pipeline_id
|
24
|
+
env["BUILDKITE_BUILD_ID"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def pipeline_name
|
28
|
+
env["BUILDKITE_PIPELINE_SLUG"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def pipeline_number
|
32
|
+
env["BUILDKITE_BUILD_NUMBER"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def pipeline_url
|
36
|
+
env["BUILDKITE_BUILD_URL"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def node_name
|
40
|
+
env["BUILDKITE_AGENT_ID"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def node_labels
|
44
|
+
labels = env
|
45
|
+
.select { |key| key.start_with?("BUILDKITE_AGENT_META_DATA_") }
|
46
|
+
.map { |key, value| "#{key.to_s.sub("BUILDKITE_AGENT_META_DATA_", "").downcase}:#{value}" }
|
47
|
+
.sort_by(&:length)
|
48
|
+
|
49
|
+
labels.to_json unless labels.empty?
|
50
|
+
end
|
51
|
+
|
52
|
+
def workspace_path
|
53
|
+
env["BUILDKITE_BUILD_CHECKOUT_PATH"]
|
54
|
+
end
|
55
|
+
|
56
|
+
def git_repository_url
|
57
|
+
env["BUILDKITE_REPO"]
|
58
|
+
end
|
59
|
+
|
60
|
+
def git_commit_sha
|
61
|
+
env["BUILDKITE_COMMIT"]
|
62
|
+
end
|
63
|
+
|
64
|
+
def git_branch
|
65
|
+
env["BUILDKITE_BRANCH"]
|
66
|
+
end
|
67
|
+
|
68
|
+
def git_tag
|
69
|
+
env["BUILDKITE_TAG"]
|
70
|
+
end
|
71
|
+
|
72
|
+
def git_commit_author_name
|
73
|
+
env["BUILDKITE_BUILD_AUTHOR"]
|
74
|
+
end
|
75
|
+
|
76
|
+
def git_commit_author_email
|
77
|
+
env["BUILDKITE_BUILD_AUTHOR_EMAIL"]
|
78
|
+
end
|
79
|
+
|
80
|
+
def git_commit_message
|
81
|
+
env["BUILDKITE_MESSAGE"]
|
82
|
+
end
|
83
|
+
|
84
|
+
def ci_env_vars
|
85
|
+
{
|
86
|
+
"BUILDKITE_BUILD_ID" => env["BUILDKITE_BUILD_ID"],
|
87
|
+
"BUILDKITE_JOB_ID" => env["BUILDKITE_JOB_ID"]
|
88
|
+
}.to_json
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Ext
|
10
|
+
module Environment
|
11
|
+
module Providers
|
12
|
+
# Circle CI: https://circleci.com/
|
13
|
+
# Environment variables docs: https://circleci.com/docs/variables/#built-in-environment-variables
|
14
|
+
class Circleci < Base
|
15
|
+
def provider_name
|
16
|
+
"circleci"
|
17
|
+
end
|
18
|
+
|
19
|
+
def job_url
|
20
|
+
env["CIRCLE_BUILD_URL"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def job_name
|
24
|
+
env["CIRCLE_JOB"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def pipeline_id
|
28
|
+
env["CIRCLE_WORKFLOW_ID"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def pipeline_name
|
32
|
+
env["CIRCLE_PROJECT_REPONAME"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def pipeline_url
|
36
|
+
"https://app.circleci.com/pipelines/workflows/#{env["CIRCLE_WORKFLOW_ID"]}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def workspace_path
|
40
|
+
env["CIRCLE_WORKING_DIRECTORY"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def git_repository_url
|
44
|
+
env["CIRCLE_REPOSITORY_URL"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def git_commit_sha
|
48
|
+
env["CIRCLE_SHA1"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def git_branch
|
52
|
+
env["CIRCLE_BRANCH"]
|
53
|
+
end
|
54
|
+
|
55
|
+
def git_tag
|
56
|
+
env["CIRCLE_TAG"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def git_commit_author_name
|
60
|
+
env["BUILD_REQUESTEDFORID"]
|
61
|
+
end
|
62
|
+
|
63
|
+
def git_commit_author_email
|
64
|
+
env["BUILD_REQUESTEDFOREMAIL"]
|
65
|
+
end
|
66
|
+
|
67
|
+
def git_commit_message
|
68
|
+
env["BUILD_SOURCEVERSIONMESSAGE"]
|
69
|
+
end
|
70
|
+
|
71
|
+
def ci_env_vars
|
72
|
+
{
|
73
|
+
"CIRCLE_WORKFLOW_ID" => env["CIRCLE_WORKFLOW_ID"],
|
74
|
+
"CIRCLE_BUILD_NUM" => env["CIRCLE_BUILD_NUM"]
|
75
|
+
}.to_json
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
require_relative "base"
|
6
|
+
|
7
|
+
module Datadog
|
8
|
+
module CI
|
9
|
+
module Ext
|
10
|
+
module Environment
|
11
|
+
module Providers
|
12
|
+
# Codefresh: https://codefresh.io/
|
13
|
+
# Environment variables docs: https://codefresh.io/docs/docs/pipelines/variables/#export-variables-to-all-steps-with-cf_export
|
14
|
+
class Codefresh < Base
|
15
|
+
def provider_name
|
16
|
+
"codefresh"
|
17
|
+
end
|
18
|
+
|
19
|
+
def job_name
|
20
|
+
env["CF_STEP_NAME"]
|
21
|
+
end
|
22
|
+
|
23
|
+
def pipeline_id
|
24
|
+
env["CF_BUILD_ID"]
|
25
|
+
end
|
26
|
+
|
27
|
+
def pipeline_name
|
28
|
+
env["CF_PIPELINE_NAME"]
|
29
|
+
end
|
30
|
+
|
31
|
+
def pipeline_url
|
32
|
+
env["CF_BUILD_URL"]
|
33
|
+
end
|
34
|
+
|
35
|
+
def git_branch_or_tag
|
36
|
+
env["CF_BRANCH"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def ci_env_vars
|
40
|
+
{
|
41
|
+
"CF_BUILD_ID" => env["CF_BUILD_ID"]
|
42
|
+
}.to_json
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|