diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-09-07 22:00:52 +0300 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-09-07 22:00:52 +0300 |
commit | cd72189fc0127e9993eebaba9569f912394cc5c9 (patch) | |
tree | 374fc58900c287ca27dec6160aec56cf5d757ff6 | |
parent | 5f33690ebbe19dd8698bf8b432a5e6740305f007 (diff) |
Import external files in Gitlab CI config
CE mirror of a10b777f8cb1902bba3964a4cbad2b1dd6bce785
-rw-r--r-- | app/models/ci/pipeline.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/config.rb | 11 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/config_spec.rb | 4 |
4 files changed, 13 insertions, 8 deletions
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 |