gitlab-org--gitlab-foss/lib/gitlab/ci/build/step.rb

43 lines
1.2 KiB
Ruby
Raw Normal View History

module Gitlab
module Ci
module Build
class Step
WHEN_ON_FAILURE = 'on_failure'.freeze
WHEN_ON_SUCCESS = 'on_success'.freeze
WHEN_ALWAYS = 'always'.freeze
2017-03-07 06:30:34 -05:00
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.script = job.commands.split("\n") if step.script.empty?
2018-03-26 13:26:52 -04:00
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
2018-03-26 13:26:52 -04:00
step.timeout = job.metadata_timeout
step.when = WHEN_ALWAYS
2017-03-07 06:30:34 -05:00
step.allow_failure = true
end
end
end
def initialize(name)
@name = name
@allow_failure = false
end
end
end
end
end