Skip to content

Commit

Permalink
Use BITBUCKET_GIT_HTTP_ORIGIN for repository url fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
anmarchenko committed Aug 25, 2023
1 parent ff3d7e7 commit 7169f7e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
15 changes: 10 additions & 5 deletions lib/datadog/ci/ext/environment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
Expand Down
30 changes: 15 additions & 15 deletions sig/datadog/ci/ext/environment.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7169f7e

Please sign in to comment.