diff options
Diffstat (limited to 'lib/gitlab')
-rw-r--r-- | lib/gitlab/ci/build/policy/refs.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/ci/yaml_processor.rb | 56 |
2 files changed, 26 insertions, 32 deletions
diff --git a/lib/gitlab/ci/build/policy/refs.rb b/lib/gitlab/ci/build/policy/refs.rb index 4f2bbd9eaac..9e1b639f12d 100644 --- a/lib/gitlab/ci/build/policy/refs.rb +++ b/lib/gitlab/ci/build/policy/refs.rb @@ -26,7 +26,7 @@ module Gitlab def matches_pattern?(pattern, pipeline) return true if pipeline.tag? && pattern == 'tags' - return true if !pipeline.tag? && pattern == 'branches' + return true if pipeline.branch? && pattern == 'branches' return true if source_to_pattern(pipeline.source) == pattern if pattern.first == "/" && pattern.last == "/" diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index d688683474c..19951f1842e 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -22,28 +22,12 @@ module Gitlab end - # REFACTORING STUB, remove this method, used only in tests. - # - def builds_for_stage_and_ref(stage, ref, tag = false, source = nil) - pipeline_stage_builds(stage, ::Ci::Pipeline.new(ref: ref, source: source, tag: tag)) - end - def builds @jobs.map do |name, _| build_attributes(name) end end - def stage_seeds(pipeline) - seeds = @stages.uniq.map do |stage| - builds = pipeline_stage_builds(stage, pipeline) - - Gitlab::Ci::Stage::Seed.new(pipeline, stage, builds) if builds.any? - end - - seeds.compact - end - def build_attributes(name) job = @jobs[name.to_sym] || {} @@ -71,21 +55,8 @@ module Gitlab }.compact } end - def self.validation_message(content) - return 'Please provide content of .gitlab-ci.yml' if content.blank? - - begin - Gitlab::Ci::YamlProcessor.new(content) - nil - rescue ValidationError, Psych::SyntaxError => e - e.message - end - end - - private - def pipeline_stage_builds(stage, pipeline) - stage_jobs = @jobs.select do |_, job| + selected_jobs = @jobs.select do |_, job| next unless job[:stage] == stage only_specs = Gitlab::Ci::Build::Policy @@ -97,9 +68,32 @@ module Gitlab except_specs.none? { |spec| spec.satisfied_by?(pipeline, path: @path) } end - stage_jobs.map { |_, job| build_attributes(job[:name]) } + selected_jobs.map { |_, job| build_attributes(job[:name]) } + end + + def stage_seeds(pipeline) + seeds = @stages.uniq.map do |stage| + builds = pipeline_stage_builds(stage, pipeline) + + Gitlab::Ci::Stage::Seed.new(pipeline, stage, builds) if builds.any? + end + + seeds.compact + end + + def self.validation_message(content) + return 'Please provide content of .gitlab-ci.yml' if content.blank? + + begin + Gitlab::Ci::YamlProcessor.new(content) + nil + rescue ValidationError, Psych::SyntaxError => e + e.message + end end + private + def initial_parsing ## # Global config |