2018-12-13 13:39:08 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
module Gitlab
|
|
|
|
module Ci
|
|
|
|
module Build
|
|
|
|
class Step
|
2019-12-04 20:38:33 +05:30
|
|
|
WHEN_ON_FAILURE = 'on_failure'
|
|
|
|
WHEN_ON_SUCCESS = 'on_success'
|
|
|
|
WHEN_ALWAYS = 'always'
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
attr_reader :name
|
|
|
|
attr_accessor :script, :timeout, :when, :allow_failure
|
|
|
|
|
|
|
|
class << self
|
|
|
|
def from_commands(job)
|
|
|
|
self.new(:script).tap do |step|
|
2017-09-10 17:25:29 +05:30
|
|
|
step.script = job.options[:before_script].to_a + job.options[:script].to_a
|
2018-05-09 12:01:36 +05:30
|
|
|
step.timeout = job.metadata_timeout
|
2017-08-17 22:00:37 +05:30
|
|
|
step.when = WHEN_ON_SUCCESS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
def from_release(job)
|
|
|
|
release = job.options[:release]
|
|
|
|
return unless release
|
|
|
|
|
|
|
|
self.new(:release).tap do |step|
|
|
|
|
step.script = Gitlab::Ci::Build::Releaser.new(config: job.options[:release]).script
|
|
|
|
step.timeout = job.metadata_timeout
|
|
|
|
step.when = WHEN_ON_SUCCESS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
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-05-09 12:01:36 +05:30
|
|
|
step.timeout = job.metadata_timeout
|
2017-08-17 22:00:37 +05:30
|
|
|
step.when = WHEN_ALWAYS
|
|
|
|
step.allow_failure = true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(name)
|
|
|
|
@name = name
|
|
|
|
@allow_failure = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|