roopakv / orbs

Swissknife! A set of useful commands / jobs in circle workflows
MIT License
29 stars 25 forks source link

Incorrect jq usage in append_string_to_params #55

Closed noisyscanner closed 4 years ago

noisyscanner commented 4 years ago

Hey, super useful orb - thank you! We are hoping that trigger-workflows-for-all-modified will substantially speed up our CI and bring the cost down.

When using the above step, it fails with the following error: image

I copied the source of this into our pipeline and added set -x for debugging - it looks like jq -cr is the culprit. Trying this locally I got the same error and it seems that jq -cr '' is correct if you want to redirect the output to a file. I will put in a PR to fix this.

roopakv commented 4 years ago

@noisyscanner what version of jq are you using? Because I know this command is being used by at least 4 company's pipelines with no issues. Maybe I should also check for versions in the beginning part of the script

roopakv commented 4 years ago

Hmm we are on the same version of jq jq-1.5-1-a5b5cbe

Could you paste a code snippet of how you are calling the orb. I remember running into this myself. It was weirdness with jq I think.

Here is the sample monorepo: https://github.com/swissknife/circle-monorepo

the recent pipelines seem to work.

Also here is how the jq -cr is supposed to work in your case. My guess is that some invalid js or is the case. The reason we don't need '' to -cr is that the input is coming from the piped command. But maybe there is some weird case I haven't encountered yet :D

image

Also I'm glad you are trying the orb out :) It has saved us a TON of time.

noisyscanner commented 4 years ago

That was a quick response! Locally I installed the same version as you mention, and dry-ran it through as you see in the commands echoed above, and got the same issue. Adding the quote after like jq -cr '' fixed it for me:

image

noisyscanner commented 4 years ago

@roopakv the command you posted also worked fine for me, but try appending > file to the end - then I get the error

roopakv commented 4 years ago

@noisyscanner all right lets give it a shot, send me a PR.

I'll have to make sure it works on the sample repo and some internal repos. as long it does we should be good :)

roopakv commented 4 years ago

you are right, the command files when adding > file. However im so confused. We are using this daily, and no pipelines are failing 🤷

oh wells! thanks for the catch

roopakv commented 4 years ago

@noisyscanner published. you should be able to use version 0.44.0 with the fix.

You should see the latest version at https://orb.swissknife.dev

thanks for the fix :)