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/build | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'lib/gitlab/ci/build')
-rw-r--r-- | lib/gitlab/ci/build/rules.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/ci/build/rules/rule/clause/changes.rb | 5 |
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/gitlab/ci/build/rules.rb b/lib/gitlab/ci/build/rules.rb index a500a0cc35d..a39afee194c 100644 --- a/lib/gitlab/ci/build/rules.rb +++ b/lib/gitlab/ci/build/rules.rb @@ -6,18 +6,31 @@ module Gitlab class Rules include ::Gitlab::Utils::StrongMemoize - Result = Struct.new(:when, :start_in, :allow_failure) do - def build_attributes + Result = Struct.new(:when, :start_in, :allow_failure, :variables) do + def build_attributes(seed_attributes = {}) { when: self.when, options: { start_in: start_in }.compact, - allow_failure: allow_failure + allow_failure: allow_failure, + yaml_variables: yaml_variables(seed_attributes[:yaml_variables]) }.compact end def pass? self.when != 'never' end + + private + + def yaml_variables(seed_variables) + return unless variables && seed_variables + + indexed_seed_variables = seed_variables.deep_dup.index_by { |var| var[:key] } + + variables.each_with_object(indexed_seed_variables) do |var, hash| + hash[var[0].to_s] = { key: var[0].to_s, value: var[1], public: true } + end.values + end end def initialize(rule_hashes, default_when:) @@ -32,7 +45,8 @@ module Gitlab Result.new( matched_rule.attributes[:when] || @default_when, matched_rule.attributes[:start_in], - matched_rule.attributes[:allow_failure] + matched_rule.attributes[:allow_failure], + matched_rule.attributes[:variables] ) else Result.new('never') diff --git a/lib/gitlab/ci/build/rules/rule/clause/changes.rb b/lib/gitlab/ci/build/rules/rule/clause/changes.rb index cbecce57163..9c2f6eea1dd 100644 --- a/lib/gitlab/ci/build/rules/rule/clause/changes.rb +++ b/lib/gitlab/ci/build/rules/rule/clause/changes.rb @@ -11,7 +11,7 @@ module Gitlab def satisfied_by?(pipeline, context) return true if pipeline.modified_paths.nil? - expanded_globs = expand_globs(pipeline, context) + expanded_globs = expand_globs(context) pipeline.modified_paths.any? do |path| expanded_globs.any? do |glob| File.fnmatch?(glob, path, File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB) @@ -19,8 +19,7 @@ module Gitlab end end - def expand_globs(pipeline, context) - return @globs unless ::Feature.enabled?(:ci_variable_expansion_in_rules_changes, pipeline.project, default_enabled: true) + def expand_globs(context) return @globs unless context @globs.map do |glob| |