Sha256: 1d419a24518dae39d51efec82f32faefe79626a555d889be959fc68e195e5e5f

Contents?: true

Size: 1.89 KB

Versions: 19

Compression:

Stored size: 1.89 KB

Contents

# frozen_string_literal: true

module Buildkite
  module Pipelines
    module Helpers
      module Retry
        def automatic_retry_on(exit_status: nil, limit: nil, signal_reason: nil)
          raise 'limit must set for `automatic_retry_on`.' unless limit

          if exit_status.nil? && signal_reason.nil?
            raise 'signal_reason or exit_status must set for `automatic_retry_on`.'
          end

          retry_value = get(:retry) || set(:retry, {})

          unless retry_value[:automatic].is_a?(Array)
            retry_value[:automatic] = []
          end

          automatic_options = { limit: limit }

          if exit_status && signal_reason
            retry_value[:automatic].delete_if do |rule|
              rule[:exit_status] == exit_status && rule[:signal_reason] == signal_reason
            end
            automatic_options[:exit_status] = exit_status
            automatic_options[:signal_reason] = signal_reason
          elsif exit_status
            retry_value[:automatic].delete_if { |rule| rule[:exit_status] == exit_status }
            automatic_options[:exit_status] = exit_status
          elsif signal_reason
            retry_value[:automatic].delete_if { |rule| rule[:signal_reason] == signal_reason }
            automatic_options[:signal_reason] = signal_reason
          end

          retry_value[:automatic].push(automatic_options)
        end

        def automatic_retry(enabled)
          retry_value = get(:retry) || set(:retry, {})
          retry_value[:automatic] = enabled
        end

        def manual_retry(allowed, reason: nil, permit_on_passed: nil)
          retry_value = get(:retry) || set(:retry, {})
          retry_value[:manual] = { allowed: allowed }
          retry_value[:manual][:reason] = reason unless reason.nil?
          retry_value[:manual][:permit_on_passed] = permit_on_passed unless permit_on_passed.nil?
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
buildkite-builder-4.15.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.14.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.13.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.12.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.11.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.10.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.8.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.7.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.6.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.5.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.4.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.3.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.5 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.4 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.3 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.2 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.1 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.2.0 lib/buildkite/pipelines/helpers/retry.rb
buildkite-builder-4.1.2 lib/buildkite/pipelines/helpers/retry.rb