Commit cd72189f authored by Matija Čupić's avatar Matija Čupić

Import external files in Gitlab CI config

CE mirror of a10b777f8cb1902bba3964a4cbad2b1dd6bce785
parent 5f33690e
......@@ -464,7 +464,7 @@ module Ci
return @config_processor if defined?(@config_processor)
@config_processor ||= begin
Gitlab::Ci::YamlProcessor.new(ci_yaml_file)
Gitlab::Ci::YamlProcessor.new(ci_yaml_file, project)
rescue Gitlab::Ci::YamlProcessor::ValidationError => e
self.yaml_errors = e.message
nil
......
......@@ -6,12 +6,17 @@ module Gitlab
class Config
ConfigError = Class.new(StandardError)
def initialize(config, opts = {})
def initialize(config, project = nil, opts = {})
initial_config = Config::Extendable
.new(build_config(config, opts))
.to_hash
if project.present?
processor = ::Gitlab::Ci::ExternalFiles::Processor.new(initial_config)
@config = processor.perform
else
@config = initial_config
end
@global = Entry::Global.new(@config)
@global.compose!
......
......@@ -7,8 +7,8 @@ module Gitlab
attr_reader :cache, :stages, :jobs
def initialize(config, opts = {})
@ci_config = Gitlab::Ci::Config.new(config, opts)
def initialize(config, project = nil, opts = {})
@ci_config = Gitlab::Ci::Config.new(config, project, opts)
@config = @ci_config.to_hash
unless @ci_config.valid?
......
......@@ -3,8 +3,9 @@ require 'fast_spec_helper'
require_dependency 'active_model'
describe Gitlab::Ci::Config do
let(:project) { create(:project, :repository) }
let(:config) do
described_class.new(yml)
described_class.new(yml, project)
end
context 'when config is valid' do
......@@ -125,7 +126,6 @@ describe Gitlab::Ci::Config do
end
end
context "when yml has valid 'includes' defined" do
let(:yml) do
<<-EOS
......
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