Sha256: 671098a07e268fd4265571b8e352f0bf093c1bdcecba41ca851ac5dc9d99fcd1

Contents?: true

Size: 1005 Bytes

Versions: 18

Compression:

Stored size: 1005 Bytes

Contents

# frozen_string_literal: true

module Buildkite
  module Builder
    class Extension
      class << self
        attr_reader :dsl

        def dsl(&block)
          @dsl = Module.new(&block) if block_given?
          @dsl
        end
      end

      attr_reader :context
      attr_reader :options

      def initialize(context, **options)
        @context = context
        @options = options

        prepare
      end

      def build
        # Override to provide extra functionality.
      end

      private

      def log
        context.logger
      end

      def buildkite
        @buildkite ||= begin
          unless Buildkite.env
            raise 'Must be in Buildkite environment to access the Buildkite API'
          end

          Buildkite::Pipelines::Api.new(Buildkite.env.api_token)
        end
      end

      def prepare
        # Override to provide extra functionality.
      end

      def pipeline(&block)
        context.dsl.instance_eval(&block)
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
buildkite-builder-3.6.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.5.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.4.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.3.2 lib/buildkite/builder/extension.rb
buildkite-builder-3.3.1 lib/buildkite/builder/extension.rb
buildkite-builder-3.3.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.2.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.1.0 lib/buildkite/builder/extension.rb
buildkite-builder-3.0.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.4.1 lib/buildkite/builder/extension.rb
buildkite-builder-2.4.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.3.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.2.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.1.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.0.0 lib/buildkite/builder/extension.rb
buildkite-builder-2.0.0.beta4 lib/buildkite/builder/extension.rb
buildkite-builder-2.0.0.beta3 lib/buildkite/builder/extension.rb
buildkite-builder-2.0.0.beta2 lib/buildkite/builder/extension.rb