diff --git a/lib/datadog/ci/ext/environment.rb b/lib/datadog/ci/ext/environment.rb index 7ed67837..a27caebc 100644 --- a/lib/datadog/ci/ext/environment.rb +++ b/lib/datadog/ci/ext/environment.rb @@ -165,18 +165,23 @@ def extract_azure_pipelines(env) end def extract_bitbucket(env) - url = "https://bitbucket.org/#{env["BITBUCKET_REPO_FULL_NAME"]}/addon/pipelines/home#" \ + pipeline_url = "https://bitbucket.org/#{env["BITBUCKET_REPO_FULL_NAME"]}/addon/pipelines/home#" \ "!/results/#{env["BITBUCKET_BUILD_NUMBER"]}" + + repository_url = filter_sensitive_info( + env["BITBUCKET_GIT_SSH_ORIGIN"] || env["BITBUCKET_GIT_HTTP_ORIGIN"] + ) + { Core::Git::Ext::TAG_BRANCH => env["BITBUCKET_BRANCH"], Core::Git::Ext::TAG_COMMIT_SHA => env["BITBUCKET_COMMIT"], - Core::Git::Ext::TAG_REPOSITORY_URL => env["BITBUCKET_GIT_SSH_ORIGIN"], + Core::Git::Ext::TAG_REPOSITORY_URL => repository_url, Core::Git::Ext::TAG_TAG => env["BITBUCKET_TAG"], - TAG_JOB_URL => url, - TAG_PIPELINE_ID => env["BITBUCKET_PIPELINE_UUID"]&.tr("{}", ""), + TAG_JOB_URL => pipeline_url, + TAG_PIPELINE_ID => env["BITBUCKET_PIPELINE_UUID"] ? env["BITBUCKET_PIPELINE_UUID"].tr("{}", "") : nil, TAG_PIPELINE_NAME => env["BITBUCKET_REPO_FULL_NAME"], TAG_PIPELINE_NUMBER => env["BITBUCKET_BUILD_NUMBER"], - TAG_PIPELINE_URL => url, + TAG_PIPELINE_URL => pipeline_url, TAG_PROVIDER_NAME => "bitbucket", TAG_WORKSPACE_PATH => env["BITBUCKET_CLONE_DIR"] } diff --git a/sig/datadog/ci/ext/environment.rbs b/sig/datadog/ci/ext/environment.rbs index cb24d7b4..d6b0dc1f 100644 --- a/sig/datadog/ci/ext/environment.rbs +++ b/sig/datadog/ci/ext/environment.rbs @@ -33,35 +33,35 @@ module Datadog def self?.normalize_ref: (untyped name) -> untyped - def self?.filter_sensitive_info: (untyped url) -> (untyped | nil) + def self?.filter_sensitive_info: (untyped url) -> (String | nil) - def self?.extract_appveyor: (untyped env) -> ::Hash[untyped, "appveyor" | untyped] + def self?.extract_appveyor: (untyped env) -> ::Hash[String, String?] - def self?.extract_azure_pipelines: (untyped env) -> ::Hash[untyped, "azurepipelines" | untyped] + def self?.extract_azure_pipelines: (untyped env) -> ::Hash[String, String?] - def self?.extract_bitbucket: (untyped env) -> ::Hash[untyped, untyped | "bitbucket"] + def self?.extract_bitbucket: (untyped env) -> ::Hash[String, String?] - def self?.extract_buddy: (untyped env) -> ::Hash[untyped, "buddy" | ::String | untyped] + def self?.extract_buddy: (untyped env) -> ::Hash[String, String?] - def self?.extract_buildkite: (untyped env) -> untyped + def self?.extract_buildkite: (untyped env) -> Hash[String, String?] - def self?.extract_circle_ci: (untyped env) -> ::Hash[untyped, untyped | ::String | "circleci"] + def self?.extract_circle_ci: (untyped env) -> ::Hash[String, String?] - def self?.extract_github_actions: (untyped env) -> ::Hash[untyped, untyped | ::String | "github"] + def self?.extract_github_actions: (untyped env) -> ::Hash[String, String?] - def self?.extract_gitlab: (untyped env) -> ::Hash[untyped, untyped | "gitlab"] + def self?.extract_gitlab: (untyped env) -> ::Hash[String, String?] - def self?.extract_jenkins: (untyped env) -> ::Hash[untyped, untyped | "jenkins"] + def self?.extract_jenkins: (untyped env) -> ::Hash[String, String?] - def self?.extract_teamcity: (untyped env) -> ::Hash[untyped, "teamcity" | untyped] + def self?.extract_teamcity: (untyped env) -> ::Hash[String, String?] - def self?.extract_travis: (untyped env) -> ::Hash[untyped, untyped | ::String | "travisci"] + def self?.extract_travis: (untyped env) -> ::Hash[String, String?] - def self?.extract_bitrise: (untyped env) -> ::Hash[untyped, "bitrise" | untyped] + def self?.extract_bitrise: (untyped env) -> ::Hash[String, String?] - def self?.extract_codefresh: (untyped env) -> ::Hash[untyped, "codefresh" | untyped] + def self?.extract_codefresh: (untyped env) -> ::Hash[String, String?] - def self?.extract_user_defined_git: (untyped env) -> untyped + def self?.extract_user_defined_git: (untyped env) -> Hash[String, String?] def self?.git_commit_users: () -> untyped