Hello!
I’m experiencing a strange behavior with my parent-child pipeline setup when passing a variable to the child pipeline.
- this var is empty by default, if it has any value, a job in the child pipeline triggers
- rule of the job worked fine when the child pipeline was used by itself, before I introduced the parent-child flow
- I debugged the same evaluation as the job rule has, the var considered empty everywhere, the job still triggers
Configuration
Parent CI config:
stages:
- debug
- triggers
variables:
TRIGGER:
value: ""
description: "Add some value to trigger mysterious job"
debug:
stage: debug
script:
- |
if [[ $TRIGGER=~ .+ ]]; then
echo "its not empty"
else
echo "its empty"
fi
trigger_flow_a:
stage: triggers
trigger:
include: .flow-a-gitlab-ci.yml
variables:
TRIGGER: $TRIGGER # same with "$TRIGGER" or "${TRIGGER}"
rules:
if: $CI_COMMIT_BRANCH == "develop" && $CI_COMMIT_MESSAGE =~ /.*\[flowA\].*/
Affected job in child
mysterious-job:
stage: mysterious
before_script:
- |
if [[ $TRIGGER=~ .+ ]]; then
echo "its not empty"
else
echo "its empty"
fi
script:
- echo "..."
rules:
- if: $CI_COMMIT_BRANCH == "develop" && $TRIGGER=~ /.+/
Versions
-
Self-managed
-
GitLab Community Edition v16.8.1
-
/w K8s runners
Debugging
Debugging in the parent with a non empty TRIGGER
shows that the value is not empty. On the other hand, the same condition evaluates to false in the child. Even with that, the job is triggered.
Looks like the variable is not passed properly, but then why does the job run?
Thank you in advance,
David
*UPDATE: made some edits to the original post as I realized regex syntax differs in script and rules blocks