Hi all
I am seeing a weird behavior in my CI/CD configuration. I have a job, which I want to run if one of my many DEPLOY variables is set to “true”. If I evaluate each variables separately, such as
rules:
- if: $DEPLOY_TO_PROD == "true" || $DEPLOY_TO_PREPROD == "true" || $DEPLOY_TO_TEST == "true"
This configuration works fine, as long as at least one DEPLOY_TO_
var is set to true, job is created. However, I wanted to make this shorter and more universal by using this
variables:
DEPLOY_TO_PROD: "true"
DEPLOY_TO_PREPROD: "false"
DEPLOY_TO_TEST: "true"
DEPLOY_TO_ANY: ${DEPLOY_TO_PROD}${DEPLOY_TO_PREPROD}${DEPLOY_TO_TEST}
job1:
rules:
- if: $DEPLOY_TO_ANY =~ /true/
Basically, I concatenate three strings and then try to look if there’s at least ONE true using regex. However, this does not work. Job is not created no matter what I put into regex. I’ve tried:
- /true/
- /^.*true/
- /^.*?true/
- /tru/
Job is not created. What am I doing wrong?
Interestingly, the job is also not created if I do
rules:
- if: $DEPLOY_TO_ANY == "truefalsetrue" # This reflects values of global vars as shown above
- if: $DEPLOY_TO_ANY == ""
But it is created if I do:
rules:
- if: $DEPLOY_TO_ANY
So, $DEPLOY_TO_ANY
is set to something… it is not empty, but what it is I’ve no idea.
Within the script, if I do echo $DEPLOY_TO_ANY
it prints truefalsetrue
, but clearly this is not the value visible to rules.