Skip to content

Commit

Permalink
extract teamcity
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Sep 4, 2023
1 parent 7a39ffe commit 67ca5fc
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
1 change: 0 additions & 1 deletion lib/datadog/ci/ext/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ module Environment
TAG_CI_ENV_VARS = "_dd.ci.env_vars"

PROVIDERS = [
["TEAMCITY_VERSION", :extract_teamcity],
["TRAVIS", :extract_travis],
["BITRISE_BUILD_SLUG", :extract_bitrise],
["CF_BUILD_ID", :extract_codefresh]
Expand Down
6 changes: 3 additions & 3 deletions lib/datadog/ci/ext/environment/extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Extractor
require_relative "providers/github_actions"
require_relative "providers/gitlab"
require_relative "providers/jenkins"
require_relative "providers/teamcity"

PROVIDERS = [
["APPVEYOR", Providers::Appveyor],
Expand All @@ -31,7 +32,8 @@ class Extractor
["CIRCLECI", Providers::Circleci],
["GITHUB_SHA", Providers::GithubActions],
["GITLAB_CI", Providers::Gitlab],
["JENKINS_URL", Providers::Jenkins]
["JENKINS_URL", Providers::Jenkins],
["TEAMCITY_VERSION", Providers::Teamcity]
]

def self.for_environment(env)
Expand Down Expand Up @@ -124,7 +126,6 @@ def git_branch
end

def git_repository_url
raise NoMethodError.new("This method must be overridden")
end

def git_tag
Expand Down Expand Up @@ -152,7 +153,6 @@ def git_commit_message
end

def git_commit_sha
raise NoMethodError.new("This method must be overridden")
end

def branch_or_tag(branch_or_tag_string)
Expand Down
32 changes: 32 additions & 0 deletions lib/datadog/ci/ext/environment/providers/teamcity.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# frozen_string_literal: true

require_relative "../extractor"

module Datadog
module CI
module Ext
module Environment
module Providers
# Teamcity: https://www.jetbrains.com/teamcity/
# Environment variables docs: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html
class Teamcity < Extractor
private

# overridden methods
def provider_name
"teamcity"
end

def job_name
env["TEAMCITY_BUILDCONF_NAME"]
end

def job_url
env["BUILD_URL"]
end
end
end
end
end
end
end
18 changes: 18 additions & 0 deletions sig/datadog/ci/ext/environment/providers/teamcity.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module Datadog
module CI
module Ext
module Environment
module Providers
class Teamcity < Extractor
private
def provider_name: () -> "teamcity"

def job_name: () -> String?

def job_url: () -> String?
end
end
end
end
end
end

0 comments on commit 67ca5fc

Please sign in to comment.