Implement regexp variables
What does this MR do and why?
Related #35438 (closed)
TODO:
-
Persistent yaml variable types to database
-
Treat regexp variables differently when evaluating variables
diff --git a/lib/gitlab/ci/build/rules/rule/clause/if.rb b/lib/gitlab/ci/build/rules/rule/clause/if.rb
index 499a265a1e2..d01a4de078f 100644
--- a/lib/gitlab/ci/build/rules/rule/clause/if.rb
+++ b/lib/gitlab/ci/build/rules/rule/clause/if.rb
@@ -9,6 +9,7 @@ def initialize(expression)
end
def satisfied_by?(pipeline, context)
+ # TODO :We need to know variable types in the variables hash here
::Gitlab::Ci::Pipeline::Expression::Statement.new(
@expression, context.variables_hash).truthful?
end
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/matches.rb b/lib/gitlab/ci/pipeline/expression/lexeme/matches.rb
index 4d65b914d8d..12c8345c518 100644
--- a/lib/gitlab/ci/pipeline/expression/lexeme/matches.rb
+++ b/lib/gitlab/ci/pipeline/expression/lexeme/matches.rb
@@ -9,6 +9,9 @@ class Matches < Lexeme::LogicalOperator
PATTERN = /=~/.freeze
def evaluate(variables = {})
+ # TODO: If the variables here aren't just a hash and have the
+ # type, we can switch the behavior here if the variable is a
+ # regexp type or not
text = @left.evaluate(variables)
regexp = @right.evaluate(variables)
return false unless regexp
Screenshots or screen recordings
These are strongly recommended to assist reviewers and reduce the time to merge your change.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Matija Čupić