jfrog-cli icon indicating copy to clipboard operation
jfrog-cli copied to clipboard

Support resulting an error code when using --fail-no-op=true and spec file

Open arrow0108 opened this issue 5 years ago • 12 comments

Dear Jfrogs,

When I use --fail-no-op=true with file download everything works fine but when using a spec file I think the behavior should change. If a path specified in a spec file is not fulfilled (no file was downloaded) - the operation should return an error code.

I hope this sounds reasonable.

arrow0108 avatar Jan 24 '20 15:01 arrow0108

Thanks for reporting this issue @arrow0108 ! fail-no-op flag is supported when using source & target path arguments and when using a spec-file. As explained in the documentation, if fail-no-op set to true, the command will return exit code 2 in case of no files are affected. In case of spec-file with multiple file entries, in case no files were downloaded at all (for all file groups), error code 2 will be returned. If this is your case, and you wand to get an acknowledgement for a specific group in your spec-file I think running it separately in a dedicated spec-file might be a proper solution.

Can you please share with us your use case and file-spec and let us know what the desired result you wish to get?

liron-shalom avatar Mar 31 '20 12:03 liron-shalom

Hi Liron,

In our case - indeed we have one spec file to download a set of artifacts. As part of our build process we gather all files (dependencies) from Artifactory and compose a delivery artifact. So if one of the files mentioned in the spec is missing we will not get a CLI error.

I understand the workaround suggested, separate to several files but I think the CLI got a spec file and didn't fulfill it should return an error.

Thanks

arrow0108 avatar Mar 31 '20 13:03 arrow0108

@arrow0108 , thanks for your reply!

I think that for this kind of use case we'll need to add some kind of "fail-no-op" property to the file-spec schema that will act differently from the "global" flag provided to the command. With that kind of property inside, we will be able to stop executing and fail the operation once a "file" entry with that property set to true will affect no files. The outer flag behaviour will stay as today, and fail the operation based on the entire command.

Please let us know what do you think of that solution.

liron-shalom avatar Apr 01 '20 09:04 liron-shalom

Sounds ok I guess or a new --fail-part-op (for partial operations :-) )

arrow0108 avatar Apr 01 '20 20:04 arrow0108

The current behavior seems counter-intuitive. Given the list of elements in the JSON spec file, I would've expected that the --fail-no-op would apply to each element rather than just the whole, similar to how --limit=1 is applied to each element in the spec file rather than only downloading one element from the whole file.

A fail-no-op property sounds like a viable solution as well.

avojak avatar Jun 15 '21 16:06 avojak

Agreed. Given the developer's expectations going from jfrog command to the file specs, I would have expected that given a single failure among multiple artifacts in a file spec would trigger an error code 2.

ntrainor1 avatar Jun 15 '21 16:06 ntrainor1

I agree that fail-no-op should either:

  • apply to each pattern in a spec file
  • each pattern in a spec file should have a separate fail-no-op property

I am currently experiencing an issue where if certain patterns fail to download any files, this "error" is silent. The only way to confirm if the download really succeeded is to dig through a long log file.

thecrabrangoon avatar Jan 24 '22 20:01 thecrabrangoon

+1 for this. I've got a similar situation where I have a spec-file to download a collection of artifacts. If any of them are NOT downloaded, I want to immediately fail my pipeline.

Currently, I'm not getting a failure code if a single artifact is not downloaded and no way to know which one isn't.

pll avatar Dec 06 '22 18:12 pll

Same situation here, and it seems like a very common scenario. There must be a way to validate that ALL the entries in the spec file are successful

pstsef-blackberry avatar Jan 25 '24 21:01 pstsef-blackberry