0

I am using jq lib in GitLab to parse deployment info from dynamic JSON to determine if deployments should be made. I am not able to get jq any(condition) working with dynamic attributes:

jq 'any(.name == "$my_value")'

Above returns always false, I've assigned a value dolle into my_value. If however, I run the same code like so, it returns true (as it should):

jq 'any(.name == "dolle")'

Here the json array that I give to jq:

[{ "name": "dolle" }, { "name": "polle" }]

What am I doing wrong?

  • Post your JSON and show us an expected output – Inian Aug 09 '22 at 08:07
  • The JSON is the array I put in the example. I wonder if select is truly mandatory as my example works if I hard code the value any is comparing .name against. – lazmat2k9 Aug 09 '22 at 08:11
  • shell variables don't expand inside single quote. Use the `--arg` syntax to pass a shell variable to jq context – Inian Aug 09 '22 at 08:13

0 Answers0