-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extract Circle CI to a separate extractor class
- Loading branch information
1 parent
c6d0401
commit 852bd81
Showing
5 changed files
with
130 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../extractor" | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
module Environment | ||
module Providers | ||
# Circle CI: https://circleci.com/ | ||
# Environment variables docs: https://circleci.com/docs/variables/#built-in-environment-variables | ||
class Circleci < Extractor | ||
private | ||
|
||
# overridden methods | ||
def provider_name | ||
"circleci" | ||
end | ||
|
||
def job_url | ||
env["CIRCLE_BUILD_URL"] | ||
end | ||
|
||
def job_name | ||
env["CIRCLE_JOB"] | ||
end | ||
|
||
def pipeline_id | ||
env["CIRCLE_WORKFLOW_ID"] | ||
end | ||
|
||
def pipeline_name | ||
env["CIRCLE_PROJECT_REPONAME"] | ||
end | ||
|
||
def pipeline_url | ||
"https://app.circleci.com/pipelines/workflows/#{env["CIRCLE_WORKFLOW_ID"]}" | ||
end | ||
|
||
def workspace_path | ||
env["CIRCLE_WORKING_DIRECTORY"] | ||
end | ||
|
||
def git_repository_url | ||
env["CIRCLE_REPOSITORY_URL"] | ||
end | ||
|
||
def git_commit_sha | ||
env["CIRCLE_SHA1"] | ||
end | ||
|
||
def git_branch | ||
env["CIRCLE_BRANCH"] | ||
end | ||
|
||
def git_tag | ||
env["CIRCLE_TAG"] | ||
end | ||
|
||
def git_commit_author_name | ||
env["BUILD_REQUESTEDFORID"] | ||
end | ||
|
||
def git_commit_author_email | ||
env["BUILD_REQUESTEDFOREMAIL"] | ||
end | ||
|
||
def git_commit_message | ||
env["BUILD_SOURCEVERSIONMESSAGE"] | ||
end | ||
|
||
def ci_env_vars | ||
{ | ||
"CIRCLE_WORKFLOW_ID" => env["CIRCLE_WORKFLOW_ID"], | ||
"CIRCLE_BUILD_NUM" => env["CIRCLE_BUILD_NUM"] | ||
}.to_json | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module Datadog | ||
module CI | ||
module Ext | ||
module Environment | ||
module Providers | ||
class Circleci < Extractor | ||
private | ||
def provider_name: () -> "circleci" | ||
|
||
def job_url: () -> String? | ||
|
||
def job_name: () -> String? | ||
|
||
def pipeline_id: () -> String? | ||
|
||
def pipeline_name: () -> String? | ||
|
||
def pipeline_url: () -> ::String | ||
|
||
def workspace_path: () -> String? | ||
|
||
def git_repository_url: () -> String? | ||
|
||
def git_commit_sha: () -> String? | ||
|
||
def git_branch: () -> String? | ||
|
||
def git_tag: () -> String? | ||
|
||
def git_commit_author_name: () -> String? | ||
|
||
def git_commit_author_email: () -> String? | ||
|
||
def git_commit_message: () -> String? | ||
|
||
def ci_env_vars: () -> ::String | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |