Sha256: fc126893a192ca28e2e77690c965e0f7ab8ad8037996e96d1ee7fa03243fe12d

Contents?: true

Size: 1.92 KB

Versions: 12

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

require "json"

require_relative "base"

module Datadog
  module CI
    module Ext
      module Environment
        module Providers
          # Circle CI: https://circleci.com/
          # Environment variables docs: https://circleci.com/docs/variables/#built-in-environment-variables
          class Circleci < Base
            def self.handles?(env)
              env.key?("CIRCLECI")
            end

            def provider_name
              Provider::CIRCLECI
            end

            def job_url
              env["CIRCLE_BUILD_URL"]
            end

            def job_name
              env["CIRCLE_JOB"]
            end

            def pipeline_id
              env["CIRCLE_WORKFLOW_ID"]
            end

            def pipeline_name
              env["CIRCLE_PROJECT_REPONAME"]
            end

            def pipeline_url
              "https://app.circleci.com/pipelines/workflows/#{env["CIRCLE_WORKFLOW_ID"]}"
            end

            def workspace_path
              env["CIRCLE_WORKING_DIRECTORY"]
            end

            def git_repository_url
              env["CIRCLE_REPOSITORY_URL"]
            end

            def git_commit_sha
              env["CIRCLE_SHA1"]
            end

            def git_branch
              env["CIRCLE_BRANCH"]
            end

            def git_tag
              env["CIRCLE_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
              {
                "CIRCLE_WORKFLOW_ID" => env["CIRCLE_WORKFLOW_ID"],
                "CIRCLE_BUILD_NUM" => env["CIRCLE_BUILD_NUM"]
              }.to_json
            end
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
datadog-ci-1.12.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.11.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.10.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.9.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.8.1 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.8.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.7.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.6.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.5.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.4.1 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.4.0 lib/datadog/ci/ext/environment/providers/circleci.rb
datadog-ci-1.3.0 lib/datadog/ci/ext/environment/providers/circleci.rb