Sha256: 2b087c92d067f9b22cd8d336a485fc11d8f40aaa6644a8a9dff2917701621fe1

Contents?: true

Size: 1.9 KB

Versions: 3

Compression:

Stored size: 1.9 KB

Contents

module Buildkite
  module Builder
    module Extensions
      class Steps < Extension
        def prepare
          context.data.steps = StepCollection.new(
            TemplateManager.new(context.root),
            PluginManager.new
          )
        end

        dsl do
          def group(label = nil, &block)
            raise "Group does not allow nested in another Group" if context.is_a?(Group)

            context.data.steps.push(Buildkite::Builder::Group.new(label, context.data.steps, &block))
          end

          def plugin(name, uri)
            context.data.steps.plugins.add(name, uri)
          end

          def block(template = nil, **args, &block)
            context.data.steps.add(Pipelines::Steps::Block, template, **args, &block)
          end

          def command(template = nil, **args, &block)
            context.data.steps.add(Pipelines::Steps::Command, template, **args, &block)
          end

          def input(template = nil, **args, &block)
            context.data.steps.add(Pipelines::Steps::Input, template, **args, &block)
          end

          def trigger(template = nil, **args, &block)
            context.data.steps.add(Pipelines::Steps::Trigger, template, **args, &block)
          end

          def skip(template = nil, **args, &block)
            step = context.data.steps.add(Pipelines::Steps::Skip, template, **args, &block)
            # A skip step has a nil/noop command.
            step.command(nil)
            # Always set the skip attribute if it's in a falsey state.
            step.skip(true) if !step.get(:skip) || step.skip.empty?
            step
          end

          def wait(attributes = {}, &block)
            step = context.data.steps.add(Pipelines::Steps::Wait, &block)
            step.wait(nil)
            attributes.each do |key, value|
              step.set(key, value)
            end
            step
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
buildkite-builder-2.0.0 lib/buildkite/builder/extensions/steps.rb
buildkite-builder-2.0.0.beta4 lib/buildkite/builder/extensions/steps.rb
buildkite-builder-2.0.0.beta3 lib/buildkite/builder/extensions/steps.rb