Module: Buildkite::Pipelines::Helpers::SoftFail

Defined in:
lib/buildkite/pipelines/helpers/soft_fail.rb

Instance Method Summary collapse

Instance Method Details

#soft_fail(*value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/buildkite/pipelines/helpers/soft_fail.rb', line 7

def soft_fail(*value)
  # soft_fail can be an array of exit_statuses or true
  # https://buildkite.com/docs/pipelines/command-step#soft-fail-attributes

  if value.first == true
    current = get('soft_fail')

    if current.is_a?(Array)
      raise ArgumentError, "Cannot set soft_fail to true when it's already an array.\nsoft_fail: #{current}"
    else
      set('soft_fail', true)
    end
  else
    super
  end
end

#soft_fail_on_status(*statuses) ⇒ Object



24
25
26
27
28
# File 'lib/buildkite/pipelines/helpers/soft_fail.rb', line 24

def soft_fail_on_status(*statuses)
  statuses.each do |status|
    soft_fail(exit_status: status)
  end
end