I have the following gitlab-ci.yaml file. And BUILD_NUMBER variable should be passed from upstream job to the downstream one (someproject). With the following configuration this trigger-job will be created and fired each time no matter if BUILD_NUMBER is in context or not:
trigger-job:
stage: build
rules:
- if: '$BUILD_NUMBER != null && $BUILD_NUMBER != ""'
variables:
BUILD_NUMBER: ${BUILD_NUMBER}
trigger:
project: someproject
branch: main
If I do remove VARIABLES instruction and just pass pipeline variables with appropriate command – everything works. Why? Does it mean that VARIABLES section runs before RULES one and initialize it to smth other than NULL or “”?
trigger-job:
stage: build
rules:
- if: '$BUILD_NUMBER != null && $BUILD_NUMBER != ""'
trigger:
project: someproject
branch: main
forward:
pipeline_variables: true