summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb20
1 files changed, 15 insertions, 5 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 965ba35c8b0..9c44e9ef5fd 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -143,9 +143,7 @@ module Ci
end
before_transition any => [:running] do |build|
- if build.specified_dependencies? && build.dependencies.empty?
- raise MissingDependenciesError
- end
+ build.validates_dependencies!
end
end
@@ -486,8 +484,20 @@ module Ci
options[:dependencies]&.empty?
end
- def specified_dependencies?
- options.has_key?(:dependencies) && options[:dependencies].any?
+ def validates_dependencies!
+ dependencies.tap do |deps|
+ # When `dependencies` keyword is given and depended jobs are skipped by `only` keyword
+ if options[:dependencies]&.any? && deps.empty?
+ raise MissingDependenciesError
+ end
+
+ # When artifacts of depended jobs have not existsed
+ deps.each do |dep|
+ if dep.options[:artifacts]&.any? && !dep.artifacts?
+ raise MissingDependenciesError
+ end
+ end
+ end
end
def hide_secrets(trace)