Sha256: 07320f175f8dbaf4de7fbaaf66dbf9376738bb856f929b8a827cf873a1ae0153

Contents?: true

Size: 1.63 KB

Versions: 3

Compression:

Stored size: 1.63 KB

Contents

# frozen_string_literal: true

require_relative "base"

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 < Base
            # 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

            private

            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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
datadog-ci-0.2.0 lib/datadog/ci/ext/environment/providers/bitbucket.rb
datadog-ci-0.1.1 lib/datadog/ci/ext/environment/providers/bitbucket.rb
datadog-ci-0.1.0 lib/datadog/ci/ext/environment/providers/bitbucket.rb