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

step.rb « build « ci « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 48111ae5717574ce0aab029cf27bb816caffaf5b (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
38
39
40
41
42
43
# frozen_string_literal: true

module Gitlab
  module Ci
    module Build
      class Step
        WHEN_ON_FAILURE = 'on_failure'
        WHEN_ON_SUCCESS = 'on_success'
        WHEN_ALWAYS = 'always'

        attr_reader :name
        attr_accessor :script, :timeout, :when, :allow_failure

        class << self
          def from_commands(job)
            self.new(:script).tap do |step|
              step.script = job.options[:before_script].to_a + job.options[:script].to_a
              step.timeout = job.metadata_timeout
              step.when = WHEN_ON_SUCCESS
            end
          end

          def from_after_script(job)
            after_script = job.options[:after_script]
            return unless after_script

            self.new(:after_script).tap do |step|
              step.script = after_script
              step.timeout = job.metadata_timeout
              step.when = WHEN_ALWAYS
              step.allow_failure = true
            end
          end
        end

        def initialize(name)
          @name = name
          @allow_failure = false
        end
      end
    end
  end
end