Fix CI rules-if comparison with Regexp variables
What does this MR do and why?
When the right side of a =~
or !~
comparison is a regexp variable, we consider this as a string. However, we need to try converting it to a regexp if possible.
In this MR, we start to try to consider the right side of an expression as a regexp.
Related to #35438 (closed)
This fix is behind a feature flag ci_fix_rules_if_comparison_with_regexp_variable
(#359740 (closed)).
Screenshots or screen recordings
- Example CI pipeline config:
variables:
teststring: 'abcde'
pattern: '/^ab.*/'
test1:
script: exit 0
rules:
- if: '$teststring =~ $pattern'
test2:
script: exit 0
rules:
- if: '$teststring =~ /^ab.*/'
- Run a pipeline;
test1
is not included in the pipeline.
- Enable
ci_fix_rules_if_comparison_with_regexp_variable
and run a pipeline;
Feature.enable(:ci_fix_rules_if_comparison_with_regexp_variable)
test1
is included in the pipeline.
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 Furkan Ayhan