Ok I think the problem is, that $() variables are not available during yaml compilation, so it cannot work. What I should use here is the "condition:" parameter inside the task instead of the if-statement and access the variable with "$()" or "variables[]" directly instead of passing it as a parameter.