Class: Gitlab::Ci::Build::Step

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/ci/build/step.rb

Constant Summary collapse

WHEN_ON_FAILURE =
'on_failure'
WHEN_ON_SUCCESS =
'on_success'
WHEN_ALWAYS =
'always'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Step

Returns a new instance of Step.


47
48
49
50
# File 'lib/gitlab/ci/build/step.rb', line 47

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

Instance Attribute Details

#allow_failureObject

Returns the value of attribute allow_failure


12
13
14
# File 'lib/gitlab/ci/build/step.rb', line 12

def allow_failure
  @allow_failure
end

#nameObject (readonly)

Returns the value of attribute name


11
12
13
# File 'lib/gitlab/ci/build/step.rb', line 11

def name
  @name
end

#scriptObject

Returns the value of attribute script


12
13
14
# File 'lib/gitlab/ci/build/step.rb', line 12

def script
  @script
end

#timeoutObject

Returns the value of attribute timeout


12
13
14
# File 'lib/gitlab/ci/build/step.rb', line 12

def timeout
  @timeout
end

#whenObject

Returns the value of attribute when


12
13
14
# File 'lib/gitlab/ci/build/step.rb', line 12

def when
  @when
end

Class Method Details

.from_after_script(job) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
# File 'lib/gitlab/ci/build/step.rb', line 34

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.
    step.when = WHEN_ALWAYS
    step.allow_failure = true
  end
end

.from_commands(job) ⇒ Object


15
16
17
18
19
20
21
# File 'lib/gitlab/ci/build/step.rb', line 15

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.
    step.when = WHEN_ON_SUCCESS
  end
end

.from_release(job) ⇒ Object


23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/ci/build/step.rb', line 23

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.
    step.when = WHEN_ON_SUCCESS
  end
end