2017-03-02 11:44:15 -05:00
|
|
|
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
|
2017-03-23 09:37:49 -04:00
|
|
|
attr_accessor :script, :timeout, :when, :allow_failure
|
2017-03-02 11:44:15 -05:00
|
|
|
|
|
|
|
class << self
|
|
|
|
def from_commands(job)
|
|
|
|
self.new(:script).tap do |step|
|
2017-07-06 10:57:34 -04:00
|
|
|
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
|
2017-03-02 11:44:15 -05:00
|
|
|
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
|
2017-03-02 11:44:15 -05:00
|
|
|
step.when = WHEN_ALWAYS
|
2017-03-07 06:30:34 -05:00
|
|
|
step.allow_failure = true
|
2017-03-02 11:44:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(name)
|
|
|
|
@name = name
|
|
|
|
@allow_failure = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|