-
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.
reshuffle code locations, extract Buddy extractor to a separate class
- Loading branch information
1 parent
1f70294
commit d01f763
Showing
21 changed files
with
600 additions
and
492 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../extractor" | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
module Environment | ||
module Providers | ||
# Appveyor: https://www.appveyor.com/ | ||
# Environment variables docs: https://www.appveyor.com/docs/environment-variables/ | ||
class Appveyor < Extractor | ||
private | ||
|
||
# overridden methods | ||
def provider_name | ||
"appveyor" | ||
end | ||
|
||
def pipeline_url | ||
url | ||
end | ||
|
||
def job_url | ||
url | ||
end | ||
|
||
def workspace_path | ||
env["APPVEYOR_BUILD_FOLDER"] | ||
end | ||
|
||
def pipeline_id | ||
env["APPVEYOR_BUILD_ID"] | ||
end | ||
|
||
def pipeline_name | ||
env["APPVEYOR_REPO_NAME"] | ||
end | ||
|
||
def pipeline_number | ||
env["APPVEYOR_BUILD_NUMBER"] | ||
end | ||
|
||
def git_repository_url | ||
return nil unless github_repo_provider? | ||
|
||
"https://github.com/#{env["APPVEYOR_REPO_NAME"]}.git" | ||
end | ||
|
||
def git_commit_sha | ||
return nil unless github_repo_provider? | ||
|
||
env["APPVEYOR_REPO_COMMIT"] | ||
end | ||
|
||
def git_branch | ||
return nil unless github_repo_provider? | ||
|
||
env["APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH"] || env["APPVEYOR_REPO_BRANCH"] | ||
end | ||
|
||
def git_tag | ||
return nil unless github_repo_provider? | ||
|
||
env["APPVEYOR_REPO_TAG_NAME"] | ||
end | ||
|
||
def git_commit_author_name | ||
env["APPVEYOR_REPO_COMMIT_AUTHOR"] | ||
end | ||
|
||
def git_commit_author_email | ||
env["APPVEYOR_REPO_COMMIT_AUTHOR_EMAIL"] | ||
end | ||
|
||
def git_commit_message | ||
commit_message = env["APPVEYOR_REPO_COMMIT_MESSAGE"] | ||
if commit_message | ||
extended = env["APPVEYOR_REPO_COMMIT_MESSAGE_EXTENDED"] | ||
commit_message = "#{commit_message}\n#{extended}" if extended | ||
end | ||
commit_message | ||
end | ||
|
||
# appveyor-specific methods | ||
|
||
def github_repo_provider? | ||
return @github_repo_provider if defined?(@github_repo_provider) | ||
|
||
@github_repo_provider = env["APPVEYOR_REPO_PROVIDER"] == "github" | ||
end | ||
|
||
def url | ||
@url ||= "https://ci.appveyor.com/project/#{env["APPVEYOR_REPO_NAME"]}/builds/#{env["APPVEYOR_BUILD_ID"]}" | ||
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,126 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../extractor" | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
module Environment | ||
module Providers | ||
# Azure Pipelines: https://azure.microsoft.com/en-us/products/devops/pipelines | ||
# Environment variables docs: https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml | ||
class Azure < Extractor | ||
private | ||
|
||
# overridden methods | ||
def provider_name | ||
"azurepipelines" | ||
end | ||
|
||
def pipeline_url | ||
return unless url_defined? | ||
|
||
@pipeline_url ||= "#{team_foundation_server_uri}#{team_project_id}/_build/results?buildId=#{build_id}" | ||
end | ||
|
||
def job_url | ||
return unless url_defined? | ||
|
||
@job_url ||= "#{pipeline_url}&view=logs&j=#{env["SYSTEM_JOBID"]}&t=#{env["SYSTEM_TASKINSTANCEID"]}" | ||
end | ||
|
||
def workspace_path | ||
env["BUILD_SOURCESDIRECTORY"] | ||
end | ||
|
||
def pipeline_id | ||
build_id | ||
end | ||
|
||
def pipeline_number | ||
build_id | ||
end | ||
|
||
def pipeline_name | ||
env["BUILD_DEFINITIONNAME"] | ||
end | ||
|
||
def stage_name | ||
env["SYSTEM_STAGEDISPLAYNAME"] | ||
end | ||
|
||
def job_name | ||
env["SYSTEM_JOBDISPLAYNAME"] | ||
end | ||
|
||
def git_repository_url | ||
env["SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI"] || env["BUILD_REPOSITORY_URI"] | ||
end | ||
|
||
def git_commit_sha | ||
env["SYSTEM_PULLREQUEST_SOURCECOMMITID"] || env["BUILD_SOURCEVERSION"] | ||
end | ||
|
||
def git_branch | ||
return @branch if defined?(@branch) | ||
|
||
set_branch_and_tag | ||
@branch | ||
end | ||
|
||
def git_tag | ||
return @tag if defined?(@tag) | ||
|
||
set_branch_and_tag | ||
@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 | ||
{ | ||
"SYSTEM_TEAMPROJECTID" => env["SYSTEM_TEAMPROJECTID"], | ||
"BUILD_BUILDID" => env["BUILD_BUILDID"], | ||
"SYSTEM_JOBID" => env["SYSTEM_JOBID"] | ||
}.to_json | ||
end | ||
|
||
# azure-specific methods | ||
|
||
def build_id | ||
env["BUILD_BUILDID"] | ||
end | ||
|
||
def team_foundation_server_uri | ||
env["SYSTEM_TEAMFOUNDATIONSERVERURI"] | ||
end | ||
|
||
def team_project_id | ||
env["SYSTEM_TEAMPROJECTID"] | ||
end | ||
|
||
def url_defined? | ||
!(build_id && team_foundation_server_uri && team_project_id).nil? | ||
end | ||
|
||
def set_branch_and_tag | ||
@branch, @tag = branch_or_tag( | ||
env["SYSTEM_PULLREQUEST_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCHNAME"] | ||
) | ||
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,71 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "../extractor" | ||
|
||
module Datadog | ||
module CI | ||
module Ext | ||
module Environment | ||
module Providers | ||
# Bitbucket Pipelines: https://bitbucket.org/product/features/pipelines | ||
# Environment variables docs: https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/ | ||
class Bitbucket < Extractor | ||
private | ||
|
||
# overridden methods | ||
def provider_name | ||
"bitbucket" | ||
end | ||
|
||
def pipeline_id | ||
env["BITBUCKET_PIPELINE_UUID"] ? env["BITBUCKET_PIPELINE_UUID"].tr("{}", "") : nil | ||
end | ||
|
||
def pipeline_name | ||
env["BITBUCKET_REPO_FULL_NAME"] | ||
end | ||
|
||
def pipeline_number | ||
env["BITBUCKET_BUILD_NUMBER"] | ||
end | ||
|
||
def pipeline_url | ||
url | ||
end | ||
|
||
def job_url | ||
url | ||
end | ||
|
||
def workspace_path | ||
env["BITBUCKET_CLONE_DIR"] | ||
end | ||
|
||
def git_repository_url | ||
env["BITBUCKET_GIT_SSH_ORIGIN"] || env["BITBUCKET_GIT_HTTP_ORIGIN"] | ||
end | ||
|
||
def git_commit_sha | ||
env["BITBUCKET_COMMIT"] | ||
end | ||
|
||
def git_branch | ||
env["BITBUCKET_BRANCH"] | ||
end | ||
|
||
def git_tag | ||
env["BITBUCKET_TAG"] | ||
end | ||
|
||
# bitbucket-specific methods | ||
|
||
def url | ||
"https://bitbucket.org/#{env["BITBUCKET_REPO_FULL_NAME"]}/addon/pipelines/home#" \ | ||
"!/results/#{env["BITBUCKET_BUILD_NUMBER"]}" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.