Fix after_script processing for Runners APIv4

This commit is contained in:
Tomasz Maczukin 2017-03-23 14:37:49 +01:00
parent 22682f6e15
commit 3878a774f1
No known key found for this signature in database
GPG Key ID: 7E9EB2E4B0F625CD
4 changed files with 8 additions and 9 deletions

View File

@ -0,0 +1,4 @@
---
title: Fix after_script processing for Runners APIv4
merge_request: 10185
author:

View File

@ -7,13 +7,12 @@ module Gitlab
WHEN_ALWAYS = 'always'.freeze
attr_reader :name
attr_writer :script
attr_accessor :timeout, :when, :allow_failure
attr_accessor :script, :timeout, :when, :allow_failure
class << self
def from_commands(job)
self.new(:script).tap do |step|
step.script = job.commands
step.script = job.commands.split("\n")
step.timeout = job.timeout
step.when = WHEN_ON_SUCCESS
end
@ -36,10 +35,6 @@ module Gitlab
@name = name
@allow_failure = false
end
def script
@script.split("\n")
end
end
end
end

View File

@ -172,7 +172,7 @@ FactoryGirl.define do
{
image: 'ruby:2.1',
services: ['postgres'],
after_script: "ls\ndate",
after_script: %w(ls date),
artifacts: {
name: 'artifacts_file',
untracked: false,

View File

@ -25,7 +25,7 @@ describe Gitlab::Ci::Build::Step do
end
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
expect(subject.name).to eq(:after_script)