summaryrefslogtreecommitdiff
path: root/lib/ci
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-08-26 12:45:36 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-08-26 12:45:36 +0200
commit326dc7da3bb7e6537095277dc8ee8ae880774b62 (patch)
treea7975f8850f5cef9fc706de3a05a7bbd49f8da82 /lib/ci
parentae99f74b77fc0f49a9efd5f71119e7de4e313629 (diff)
downloadgitlab-ce-326dc7da3bb7e6537095277dc8ee8ae880774b62.tar.gz
Check if kubernetes required before creating a job
Diffstat (limited to 'lib/ci')
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index 3efd9b3bdac..72a38e97648 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -44,6 +44,22 @@ module Ci
end
end
+ def pipeline_stage_builds(stage, pipeline)
+ builds = builds_for_stage_and_ref(
+ stage, pipeline.ref, pipeline.tag?, pipeline.source)
+
+ builds.select do |build|
+ job = @jobs[build.fetch(:name).to_sym]
+ has_kubernetes = pipeline.has_kubernetes_available?
+ only_kubernetes = job.dig(:only, :kubernetes)
+ except_kubernetes = job.dig(:except, :kubernetes)
+
+ [!only_kubernetes & !except_kubernetes,
+ only_kubernetes & has_kubernetes,
+ except_kubernetes & !has_kubernetes].any?
+ end
+ end
+
def builds
@jobs.map do |name, _|
build_attributes(name)
@@ -52,8 +68,7 @@ module Ci
def stage_seeds(pipeline)
seeds = @stages.uniq.map do |stage|
- builds = builds_for_stage_and_ref(
- stage, pipeline.ref, pipeline.tag?, pipeline.source)
+ builds = pipeline_stage_builds(stage, pipeline)
Gitlab::Ci::Stage::Seed.new(pipeline, stage, builds) if builds.any?
end