I am currently trying to append a directory name to a command based on a boolean parameter value
e.g
parameter is defined as:
name: shared
type: boolean
this should then be added to my command execution via the text template syntax… but i cannot find any documentation on this … the samples only show the “if” case not the else case … let me show what i want:
so the result would be
cmake xxx -o targetpath/somepath/shared if the parameter shared is true, and
cmake xxx -o targetpath/somepath/static if the parameter shared is false…
exactly, i mean i can use bash there, but bash on windows has problems with cmake parameter parsing ( i have to call that via cmd.exe to make it work )
Gotcha. Well, in the interests of getting it working immediately, you could use a scripting language that works identically on all platforms, such as PHP or Python (assuming the parameter can be passed from the step to the script).
From there, you can always refactor if and when it becomes clearer how to do this in a more native way. (This approach serves me well generally - rather than spend hours/days on working out how to do something the correct way, I make a reasonably clean hack and then create a ticket to clean it up. Sometimes I am reasonably satisfied with the hack and decide to leave it be anyway).
While the “if”/“truthy” check is: <<# parameters.all >> -a <</ parameters.all >>
the “if not”/“falsey” check is: <<^ parameters.short >> -l <</ parameters.short >>
There is a support document for the syntax. I can not post links, but go to support dot circleci dot com, and then search for “Using Mustache Conditionals in Config File”. You should see article ID 4417604103835 by Aaron, September 2022.
I think it is misleading to call these “Mustache Conditionals”. Since mustache uses curly braces, a section would look like: