You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have another example where conditional logic would help.
Here, I would like to define TAG_HASH at the beginning of the justfile.
This variable is reused in many targets so I don't want to re-set it in each target: it should be set once.
# if running in jenkins, set the tag to the git sha of the folder, else, create a hash of the folderFOLDER_HASH := `find docker/myfolder -type f | sort -u | xargs cat | md5sum | cut -c1-7`FOLDER_GIT_SHA := `git log -1 --oneline docker/myfolder | cut -d'' -f 1`TAG_HASH := `[[ "{{JENKINS_URL}}"!="" ]] &&echo {{FOLDER_GIT_SHA}} ||echo {{FOLDER_HASH}}`
That last line is already not very readable, but {{JENKINS_URL}}, {{FOLDER_GIT_SHA}} and {{FOLDER_HASH}} are empty in the line above.
(because the variables inside {{ }} are not replaced by their values (this happens only at the beginning of the file, it works in targets. Could it be a bug?).
Thanks for posting this! Could you elaborate on what's happening here? Backticks in variables outside of recipes are evaluated before any recipe runs. Is that not happening?
The text was updated successfully, but these errors were encountered:
Backticks in variables outside of recipes are evaluated before any recipe runs, yes, but it doesn't seem possible to use the result of this evalation inside other backticks. Here is a simpler example:
Ah, okay, gotcha. I would like to come up with a backwards compatible way to use interpolations inside of strings and backticks. I think copying python's f-strings would be a good idea:
Quoting @kenden from #674 (comment):
Thanks for posting this! Could you elaborate on what's happening here? Backticks in variables outside of recipes are evaluated before any recipe runs. Is that not happening?
The text was updated successfully, but these errors were encountered: