Import external files in Gitlab CI config

CE mirror of a10b777f8cb1902bba3964a4cbad2b1dd6bce785
This commit is contained in:
Matija Čupić 2018-09-07 21:00:52 +02:00
parent 5f33690ebb
commit cd72189fc0
No known key found for this signature in database
GPG key ID: 4BAF84FFACD2E5DE
4 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -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!

View file

@ -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?

View file

@ -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