summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-31 15:13:40 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-31 15:13:40 +0200
commitc72e21fd9764845a107005562ff8ce1c06cac431 (patch)
tree1acd707d049036bd532046b91e5f25d55633744e /lib
parentc881425b665b9c0b022dc2e213486aecc320ec7e (diff)
downloadgitlab-ce-c72e21fd9764845a107005562ff8ce1c06cac431.tar.gz
Return stage seeds object from YAML processor
Diffstat (limited to 'lib')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb12
-rw-r--r--lib/gitlab/ci/stage/seeds.rb6
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 5e6c3d029c6..4b0e87a945b 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -50,14 +50,14 @@ module Ci
end
end
- def stages_for_ref(ref, tag = false, trigger_request = nil)
- stages = @stages.uniq.map do |stage|
- builds = builds_for_stage_and_ref(stage, ref, tag, trigger_request)
+ def stage_seeds(ref:, tag: false, trigger: nil)
+ Gitlab::Ci::Stage::Seeds.new.tap do |seeds|
+ @stages.uniq.each do |stage|
+ builds = builds_for_stage_and_ref(stage, ref, tag, trigger)
- { name: stage, builds_attributes: builds.to_a } if builds.any?
+ seeds.append_stage(stage, builds) if builds.any?
+ end
end
-
- stages.compact.sort_by { |stage| @stages.index(stage[:name]) }
end
def build_attributes(name)
diff --git a/lib/gitlab/ci/stage/seeds.rb b/lib/gitlab/ci/stage/seeds.rb
index 16c436b5d4f..cb5174a166b 100644
--- a/lib/gitlab/ci/stage/seeds.rb
+++ b/lib/gitlab/ci/stage/seeds.rb
@@ -8,6 +8,10 @@ module Gitlab
@stages = []
end
+ def has_stages?
+ @stages.any?
+ end
+
def stages
@stages.map(&:stage)
end
@@ -48,7 +52,7 @@ module Gitlab
end
def to_attributes
- @stages.map.with_index do |seed|
+ @stages.map do |seed|
seed.stage.merge(builds_attributes: seed.jobs)
end
end