Commit fb8210ad authored by Tomasz Maczukin's avatar Tomasz Maczukin

Update step data naming

parent 65564598
...@@ -720,7 +720,7 @@ module API ...@@ -720,7 +720,7 @@ module API
end end
class Step < Grape::Entity class Step < Grape::Entity
expose :name, :script, :timeout, :condition, :result expose :name, :script, :timeout, :when, :allow_failure
end end
class Image < Grape::Entity class Image < Grape::Entity
......
...@@ -3,21 +3,19 @@ module Gitlab ...@@ -3,21 +3,19 @@ module Gitlab
module Build module Build
module Response module Response
class Step class Step
CONDITION_IF_SUCCEEDED = 'run_if_succeeded' CONDITION_ON_FAILURE = 'on_failure'
CONDITION_ALWAYS = 'run_always' CONDITION_ON_SUCCESS = 'on_success'
CONDITION_ALWAYS = 'always'
RESULT_FAILS_JOB = 'fails_job' attr_reader :name, :script, :when, :allow_failure, :timeout
RESULT_DOESNT_FAIL_JOB = 'doesnt_fail_job'
attr_reader :name, :script, :condition, :result, :timeout
class << self class << self
def from_commands(build) def from_commands(build)
self.new(:script, self.new(:script,
build.commands, build.commands,
build.timeout, build.timeout,
CONDITION_IF_SUCCEEDED, CONDITION_ON_SUCCESS,
RESULT_FAILS_JOB) false)
end end
def from_after_script(build) def from_after_script(build)
...@@ -28,16 +26,16 @@ module Gitlab ...@@ -28,16 +26,16 @@ module Gitlab
after_script, after_script,
build.timeout, build.timeout,
CONDITION_ALWAYS, CONDITION_ALWAYS,
RESULT_DOESNT_FAIL_JOB) true)
end end
end end
def initialize(name, script, timeout, condition = CONDITION_IF_SUCCEEDED, result = RESULT_FAILS_JOB) def initialize(name, script, timeout, when_condition = CONDITION_ON_SUCCESS, allow_failure = true)
@name = name @name = name
@script = script.split("\n") @script = script.split("\n")
@timeout = timeout @timeout = timeout
@condition = condition @when = when_condition
@result = result @allow_failure = allow_failure
end end
end end
end end
......
...@@ -283,8 +283,8 @@ describe API::Runner do ...@@ -283,8 +283,8 @@ describe API::Runner do
expect(json_response['steps']).to include({ 'name' => 'after_script', expect(json_response['steps']).to include({ 'name' => 'after_script',
'script' => ['ls', 'date'], 'script' => ['ls', 'date'],
'timeout' => job.timeout, 'timeout' => job.timeout,
'condition' => Gitlab::Ci::Build::Response::Step::CONDITION_ALWAYS, 'when' => 'always',
'result' => Gitlab::Ci::Build::Response::Step::RESULT_DOESNT_FAIL_JOB }) 'allow_failure' => true })
expect(json_response['variables']).to include({ 'key' => 'CI_BUILD_NAME', 'value' => 'spinach', 'public' => true }, expect(json_response['variables']).to include({ 'key' => 'CI_BUILD_NAME', 'value' => 'spinach', 'public' => true },
{ 'key' => 'CI_BUILD_STAGE', 'value' => 'test', 'public' => true }, { 'key' => 'CI_BUILD_STAGE', 'value' => 'test', 'public' => true },
{ 'key' => 'DB_NAME', 'value' => 'postgres', 'public' => true }) { 'key' => 'DB_NAME', 'value' => 'postgres', 'public' => true })
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment