Sha256: 9e43bc63d69ffc3566dc0b27d7eeebc974304c49b62500c77bef5ac55bcd0d8c

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

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

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

            if emoji
              emoji = Array(emoji).map { |name| ":#{name}:" }.join
              label = [emoji, label].compact.join(' ')
            end

            context.data.steps.push(Buildkite::Builder::Group.new(label, context, &block))
          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

1 entries across 1 versions & 1 rubygems

Version Path
buildkite-builder-3.9.0 lib/buildkite/builder/extensions/steps.rb