Commit 3878a774 authored by Tomasz Maczukin's avatar Tomasz Maczukin

Fix after_script processing for Runners APIv4

parent 22682f6e
---
title: Fix after_script processing for Runners APIv4
merge_request: 10185
author:
...@@ -7,13 +7,12 @@ module Gitlab ...@@ -7,13 +7,12 @@ module Gitlab
WHEN_ALWAYS = 'always'.freeze WHEN_ALWAYS = 'always'.freeze
attr_reader :name attr_reader :name
attr_writer :script attr_accessor :script, :timeout, :when, :allow_failure
attr_accessor :timeout, :when, :allow_failure
class << self class << self
def from_commands(job) def from_commands(job)
self.new(:script).tap do |step| self.new(:script).tap do |step|
step.script = job.commands step.script = job.commands.split("\n")
step.timeout = job.timeout step.timeout = job.timeout
step.when = WHEN_ON_SUCCESS step.when = WHEN_ON_SUCCESS
end end
...@@ -36,10 +35,6 @@ module Gitlab ...@@ -36,10 +35,6 @@ module Gitlab
@name = name @name = name
@allow_failure = false @allow_failure = false
end end
def script
@script.split("\n")
end
end end
end end
end end
......
...@@ -172,7 +172,7 @@ FactoryGirl.define do ...@@ -172,7 +172,7 @@ FactoryGirl.define do
{ {
image: 'ruby:2.1', image: 'ruby:2.1',
services: ['postgres'], services: ['postgres'],
after_script: "ls\ndate", after_script: %w(ls date),
artifacts: { artifacts: {
name: 'artifacts_file', name: 'artifacts_file',
untracked: false, untracked: false,
......
...@@ -25,7 +25,7 @@ describe Gitlab::Ci::Build::Step do ...@@ -25,7 +25,7 @@ describe Gitlab::Ci::Build::Step do
end end
context 'when after_script is not empty' do context 'when after_script is not empty' do
let(:job) { create(:ci_build, options: { after_script: "ls -la\ndate" }) } let(:job) { create(:ci_build, options: { after_script: ['ls -la', 'date'] }) }
it 'fabricates an object' do it 'fabricates an object' do
expect(subject.name).to eq(:after_script) expect(subject.name).to eq(:after_script)
......
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