jfrog / jfrog-cli

JFrog CLI is a client that provides a simple interface that automates access to the JFrog products.
https://www.jfrog.com/confluence/display/CLI/JFrog+CLI
Apache License 2.0
529 stars 223 forks source link

Support AQL Sort and Limit #56

Closed DavidGamba closed 6 years ago

DavidGamba commented 7 years ago

Currently, when using the CLI for artifactory I can't limit or sort my results. This is the command I am using:

jfrog rt s --spec=query-aql.json

{
  "files": [
    {
      "aql": {
        "items.find": {
          "repo": "repo",
          "$and": [
            {
              "path": { "$match": "path/*"},
              "name": { "$match": "*.rpm"}
            }
          ]
        }
      },
      "sort": {
        "$asc": ["modified"]
      },
      "limit": 1
    }
  ]
}

I would like to be able to narrow down my results to one and then use the same spec to download the files with:

jfrog rt dl --spec=query-aql.json

Otherwise I need a high level language to parse the json output and filter stuff. But that is the purpose behind AQL, right?

Related stack overflow question: http://stackoverflow.com/q/44077569/1601989

eyalbe4 commented 7 years ago

Thanks for sharing the need @DavidGamba We'll look into addidng sort and limit support in the future and as always, welcome a pull request from the community to help us deliver this.

eyalbe4 commented 6 years ago

@DavidGamba and @jgeorgeson, Version 1.12.0 added support for sort and limit, by adding sort-by, sort-order and limit both as command line options and File Spec properties. See the documentation for more information. We'd also appreciate your feedback for the new functionality.

jgeorgeson commented 6 years ago

Working nicely in my end!

MichaelSiggelkowRnS commented 6 years ago

For me it seems only to work as command line parameter but not in spec file.

eyalbe4 commented 6 years ago

@MichaelSiggelkowRnS, Can you please share with us the spec that you used? Does your spec include the new sort-by properly?

MichaelSiggelkowRnS commented 6 years ago

My spec file looks like { "files": [ { "pattern" : "repo/test/*", "sort-by" : "path", "sort-order" : "asc", "limit": 2 } ] } which results on the debug output as

items.find({"repo": "repo","path": {"$ne": "."},"$or": [{"$and":[{"path": {"$match": "test"},"name": {"$match": "*"}}]},{"$and":[{"path": {"$match": "test/*"},"name": {"$match": "*"}}]}]}).include("name","repo","path","actual_md5","actual_sha1","size","type").limit(2)

Where as if I use the command line as jfrog.exe rt s repo/test/* --sort-by "path" --sort-order "desc" it resuls in the debug output as items.find({"repo": "repo","path": {"$ne": "."},"$or": [{"$and":[{"path": {"$match": "test"},"name": {"$match": "*"}}]},{"$and":[{"path": {"$match": "test/*"},"name": {"$match": "*"}}]}]}).include("name","repo","path","actual_md5","actual_sha1","size","type").sort({"$desc":["path"]})

Thanks!

ortsi commented 6 years ago

@MichaelSiggelkowRnS , thanks for your input! We had a problem with our documentation. the correct format for the sort params in a spec file are: sortBy and sortOrder (as opposed to sort-by and sort-order). We have fixed the documentation accordingly.
Please check and let us know if your problem is fixed.

Thanks again!

MichaelSiggelkowRnS commented 6 years ago

@ortsi Thanks a lot! That works for me now! One more question: Will this also be supported for Jenkins PlugIn? According to https://www.jfrog.com/confluence/display/RTF/Using+File+Specs file specs should work same way for jenkins and cli ... Thanks!

eyalbe4 commented 6 years ago

@MichaelSiggelkowRnS, Thanks for your feedback! Currently the sorting functionality is implemented in JFrog CLI only. We do however plan to implement this functionality in the build info project, which is used by the Jenkins, TeamCity and Bamboo Artifactory plugins. Since the File Spec schema of JFrog CLI and the other CI plugins may not always be identical, we'll modify the File Specs documentation page, so that it references the File Specs section which is specific to JFrog CLI.

MichaelSiggelkowRnS commented 6 years ago

@eyalbe4 Thank you for the update. I am really looking for a way that would allow to have one input format that could be used by CLI (for developer PCS) and by jenkins. So having one file spec format (and behaviour) would be much appreciated. Thanks!

eyalbe4 commented 6 years ago

Thank you all for the feedback. I think that this issue can be closed.