Skip to content
Snippets Groups Projects
Commit cf53d798 authored by Grzegorz Bizon's avatar Grzegorz Bizon
Browse files

Extract jobs config to separate key in config hash

parent 06c7d6f3
No related branches found
No related tags found
1 merge request!5087Move CI job config entries from legacy to new config
Pipeline #
Loading
Loading
@@ -36,6 +36,22 @@ module Gitlab
helpers :before_script, :image, :services, :after_script,
:variables, :stages, :types, :cache
 
def initialize(config)
return super(config) unless config.is_a?(Hash)
jobs = config.except(*self.class.nodes.keys)
global = config.slice(*self.class.nodes.keys)
super(global.merge(jobs: jobs))
end
##
# Temporary refactoring stub
#
def jobs
@config[:jobs]
end
def stages
stages_defined? ? stages_value : types_value
end
Loading
Loading
Loading
Loading
@@ -22,7 +22,9 @@ describe Gitlab::Ci::Config::Node::Global do
variables: { VAR: 'value' },
after_script: ['make clean'],
stages: ['build', 'pages'],
cache: { key: 'k', untracked: true, paths: ['public/'] } }
cache: { key: 'k', untracked: true, paths: ['public/'] },
rspec: { script: 'rspec' },
spinach: { script: 'spinach' } }
end
 
describe '#process!' do
Loading
Loading
@@ -120,6 +122,14 @@ describe Gitlab::Ci::Config::Node::Global do
.to eq(key: 'k', untracked: true, paths: ['public/'])
end
end
describe '#jobs' do
it 'returns jobs configuration' do
expect(global.jobs)
.to eq(rspec: { script: 'rspec' },
spinach: { script: 'spinach' })
end
end
end
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment