diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 2955e0b2bca..f3a40204305 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -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 diff --git a/lib/gitlab/ci/config.rb b/lib/gitlab/ci/config.rb index 94b2fbc082b..f665ace7c74 100644 --- a/lib/gitlab/ci/config.rb +++ b/lib/gitlab/ci/config.rb @@ -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 - processor = ::Gitlab::Ci::ExternalFiles::Processor.new(initial_config) - @config = processor.perform + + 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! diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index 5d1864ae9e2..702bcd3802d 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -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? diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb index 99896b9be5d..57354e12aa3 100644 --- a/spec/lib/gitlab/ci/config_spec.rb +++ b/spec/lib/gitlab/ci/config_spec.rb @@ -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