Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reason.rb « status « build « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 82e07faef63883c2ad63010715dc145d7ec57eaa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module Gitlab
  module Ci
    module Build
      module Status
        class Reason
          attr_reader :build, :failure_reason, :exit_code

          def initialize(build, failure_reason, exit_code = nil)
            @build = build
            @failure_reason = failure_reason
            @exit_code = exit_code
          end

          def failure_reason_enum
            ::CommitStatus.failure_reasons[failure_reason]
          end

          def force_allow_failure?
            return false if exit_code.nil?

            !build.allow_failure? && build.allowed_to_fail_with_code?(exit_code)
          end

          def self.fabricate(build, reason)
            if reason.is_a?(self)
              new(build, reason.failure_reason, reason.exit_code)
            else
              new(build, reason)
            end
          end
        end
      end
    end
  end
end