Class: Buildkite::Builder::Extensions::Steps

Inherits:
Buildkite::Builder::Extension show all
Defined in:
lib/buildkite/builder/extensions/steps.rb

Instance Attribute Summary collapse

Attributes inherited from Buildkite::Builder::Extension

#context, #options, #options_block

Instance Method Summary collapse

Methods inherited from Buildkite::Builder::Extension

#build, dsl, #initialize

Constructor Details

This class inherits a constructor from Buildkite::Builder::Extension

Instance Attribute Details

#templatesObject (readonly)

Returns the value of attribute templates.



5
6
7
# File 'lib/buildkite/builder/extensions/steps.rb', line 5

def templates
  @templates
end

Instance Method Details

#build_step(step_class, template_name, **args, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/buildkite/builder/extensions/steps.rb', line 12

def build_step(step_class, template_name, **args, &block)
  template = @templates.find(template_name)

  step_class.new(**args).tap do |step|
    step.process(template) if template
    step.process(block) if block_given?

    if @current_group
      @current_group.steps.push(step)
    else
      context.data.steps.push(step)
    end
  end
end

#prepareObject



7
8
9
10
# File 'lib/buildkite/builder/extensions/steps.rb', line 7

def prepare
  @templates = TemplateManager.new(context.root)
  context.data.steps = StepCollection.new
end

#with_group(group, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/buildkite/builder/extensions/steps.rb', line 27

def with_group(group, &block)
  raise "Group cannot be nested" if @current_group

  @current_group = group

  group.process(block)
  context.data.steps.push(group).last
ensure
  @current_group = nil
end