Fixes parsing of chained OR/AND conditions in input rules
What does this MR do and why?
Fixes parsing of chained OR/AND conditions in input rules by flattening consecutive operations of the same type into a single level.
Problem: Chained conditions like A || B || C || D were being parsed as nested binary trees instead of flat arrays.
Changelog: fixed
Fixed: #584832 (closed)
How to reproduce
-
Create a
.gitlab-ci.ymlwith chained OR conditions:spec: inputs: main_selector: default: "Undefined" options: - "Undefined" - "Choice 1" - "Choice 2" - "Choice 3" - "Choice 4" - "Choice 5" - "Choice 6" param_123: rules: - if: $[[inputs.main_selector]] == "Choice 1" || $[[inputs.main_selector]] == "Choice 2" || $[[inputs.main_selector]] == "Choice 3" default: "Value A" options: [ "Value A" ] param_456: rules: - if: $[[inputs.main_selector]] == "Choice 4" || $[[inputs.main_selector]] == "Choice 5" || $[[inputs.main_selector]] == "Choice 6" default: "Value B" options: [ "Value B" ] param_123456: rules: - if: $[[inputs.main_selector]] == "Choice 1" || $[[inputs.main_selector]] == "Choice 2" || $[[inputs.main_selector]] == "Choice 3" || $[[inputs.main_selector]] == "Choice 4" || $[[inputs.main_selector]] == "Choice 5" || $[[inputs.main_selector]] == "Choice 6" default: "Value C" options: [ "Value C" ] param_123456_2x3: rules: - if: ( $[[inputs.main_selector]] == "Choice 1" || $[[inputs.main_selector]] == "Choice 2" || $[[inputs.main_selector]] == "Choice 3" ) || ( $[[inputs.main_selector]] == "Choice 4" || $[[inputs.main_selector]] == "Choice 5" || $[[inputs.main_selector]] == "Choice 6" ) default: "Value C" options: [ "Value C" ] param_123456_3x2: rules: - if: ( $[[inputs.main_selector]] == "Choice 1" || $[[inputs.main_selector]] == "Choice 2" ) || ( $[[inputs.main_selector]] == "Choice 3" || $[[inputs.main_selector]] == "Choice 4" ) || ( $[[inputs.main_selector]] == "Choice 5" || $[[inputs.main_selector]] == "Choice 6" ) default: "Value C" options: [ "Value C" ] --- info: script: | echo 'main_selector = $[[inputs.main_selector]]' echo 'param_123 = $[[inputs.param_123]]' echo 'param_456 = $[[inputs.param_456]]' echo 'param_123456 = $[[inputs.param_123456]]' echo 'param_123456_2x3 = $[[inputs.param_123456_2x3]]' echo 'param_123456_3x2 = $[[inputs.param_123456_3x2]]'
The values should be as follows in the UI:
main_selector = "Undefined":
- Nothing appears (no inputs show up)
main_selector = "Choice 1":
- param_123 (Value A)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
main_selector = "Choice 2":
- param_123 (Value A)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
main_selector = "Choice 3":
- param_123 (Value A)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
main_selector = "Choice 4":
- param_456 (Value B)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
main_selector = "Choice 5":
- param_456 (Value B)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
main_selector = "Choice 6":
- param_456 (Value B)
- param_123456 (Value C) ← KEY TEST
- param_123456_2x3 (Value C)
- param_123456_3x2 (Value C)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
Edited by Laura Montemayor

