Codefresh provides a mechanism that allows the pipelines to retrieve variables. The normal way to do so is to use the ${{VARIABLE}} format.
I have encountered multiple times an unexpected behavior while using this format: Whenever a variable is not available it does not get replaced and the placeholder simply stays there as-is.
As an example if I try to use the variable ${{MYVARIABLE} which has not been defined, the final YAML won’t have an empty string as a replacement to the placeholder, nor will the pipeline fail because there is an undefined variable. The placeholder will simply stay there as it is.
To make things even worse, the system provided variable that I always expected to be set to some value turned out not being set in multiple occasions.
I’d like to bring as an example the CF_PULL_REQUEST_TARGET, the expected behavior is that this variable will be empty when the pipeline is manually run or the webhook event is not a pull request. The result instead is that the variable is not available and the placeholder doesn’t get replaced.
This behavior is also inconsistent with the normal behavior of the dollar $ in UNIX systems (e.g. echo $MYVARIABLE) used to access environment variables.
As a side note, I think that undefined variables should just return a warning - and maybe a “strict mode” could be optionally enabled to force undefined variables to generate an error.
A strict mode could be used, of course, for other purposes as well.
Any update on this? I get bit by the placeholder getting used as the default value quite often. Making this more standard (empty string, or offer a default set mechanism) would be great.
We have been discussing this issue internally for a long time. We agree that the requested behavior makes more sense. However, changing that now will break all existing pipelines for all customers. So it is a tradeoff between convenience and backwards compatibility.
Stay tuned, we have a possible solution in the works.