diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /lib/gitlab/ci/config/entry/need.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/ci/config/entry/need.rb')
-rw-r--r-- | lib/gitlab/ci/config/entry/need.rb | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/gitlab/ci/config/entry/need.rb b/lib/gitlab/ci/config/entry/need.rb index abfffb7a5ed..46191eca842 100644 --- a/lib/gitlab/ci/config/entry/need.rb +++ b/lib/gitlab/ci/config/entry/need.rb @@ -8,7 +8,19 @@ module Gitlab strategy :JobString, if: -> (config) { config.is_a?(String) } strategy :JobHash, - if: -> (config) { config.is_a?(Hash) && config.key?(:job) && !(config.key?(:project) || config.key?(:ref)) } + if: -> (config) { config.is_a?(Hash) && same_pipeline_need?(config) } + + strategy :CrossPipelineDependency, + if: -> (config) { config.is_a?(Hash) && cross_pipeline_need?(config) } + + def self.same_pipeline_need?(config) + config.key?(:job) && + !(config.key?(:project) || config.key?(:ref) || config.key?(:pipeline)) + end + + def self.cross_pipeline_need?(config) + config.key?(:job) && config.key?(:pipeline) && !config.key?(:project) + end class JobString < ::Gitlab::Config::Entry::Node include ::Gitlab::Config::Entry::Validatable @@ -50,6 +62,30 @@ module Gitlab end end + class CrossPipelineDependency < ::Gitlab::Config::Entry::Node + include ::Gitlab::Config::Entry::Validatable + include ::Gitlab::Config::Entry::Attributable + + ALLOWED_KEYS = %i[pipeline job artifacts].freeze + attributes :pipeline, :job, :artifacts + + validations do + validates :config, presence: true + validates :config, allowed_keys: ALLOWED_KEYS + validates :pipeline, type: String, presence: true + validates :job, type: String, presence: true + validates :artifacts, boolean: true, allow_nil: true + end + + def type + :cross_dependency + end + + def value + super.merge(artifacts: artifacts || artifacts.nil?) + end + end + class UnknownStrategy < ::Gitlab::Config::Entry::Node def type end |