Simon Josefsson simon@josefsson.org writes:
Niels Möller nisse@lysator.liu.se writes:
rules:
- if: $SSH_PRIVATE_KEY != "" && $S390X_ACCOUNT != ""
Shouldn't that be something like this:
rules:
- if: $SSH_PRIVATE_KEY != "" && $S390X_ACCOUNT != "" when: never
No, the intention was that in the current environment without the keys and settings needed for this job, $SSH_PRIVATE_KEY != "" should be false, and rule not match. The additional default rule "- when: never" is redundant, by my reading of the docs, I tried adding it only because I read some recommendation to be explicit about the default behavior (no rule matching).
But I think I really don't get quoting, in yaml in general and in these expressions. I suspected there might be that null != "" is evaluated as true, so to get null values treated as empty strings I tried adding quotes,
- if: "$SSH_PRIVATE_KEY" != "" && "$S390X_ACCOUNT" != ""
However, that results in syntax error from gitlab. Then I tried the opposite, removing both quotes and comparisons,
- if: $SSH_PRIVATE_KEY && $S390X_ACCOUNT
That appears to be syntactically correct, and it evaluates to false. I haven't yet tested what happens if those variables are assigned non-empty values, but I'd hope this is the right way to do it.
Regards, /Niels