How can I download last artifact in Artifactory?
Asked Answered
M

3

6

I have some artifacts in Artifactory (OpenSource):

enter image description here

I can download an artifact from using jfrog CLI:

jfrog rt config --user=admin --password=**** --url=http://foo:8081/artifactory
jfrog rt download testproject/01_Develop/01_CI/HPCC-Package-70.zip --flat=true

How can I download the LATEST(highest number) artifact?

Metcalfe answered 28/12, 2016 at 12:38 Comment(0)
H
12

You can use the JFrog Cli search command.

jfrog rt s "testproject/01_Develop/01_CI/HPCC-Package-*.zip"

The search command will return a list of paths which you can then sort using external tools such as jq.

Hatten answered 28/12, 2016 at 16:4 Comment(0)
H
23

JFrog CLI recently started supporting 3 new options from many of the Artifactory commands: --sort-by --sort-order and --limit.

You can use these options to search, download, copy, move or delete the latest artifact created in Artifactory. For example, to download the latest file uploaded to the all-my-frogs folder in the my-local-repo repository, use the following command:

jfrog rt dl  "my-local-repo/all-my-frogs/" --sort-by=created
--sort-order=desc --limit=1
Hodess answered 20/11, 2017 at 20:50 Comment(0)
H
12

You can use the JFrog Cli search command.

jfrog rt s "testproject/01_Develop/01_CI/HPCC-Package-*.zip"

The search command will return a list of paths which you can then sort using external tools such as jq.

Hatten answered 28/12, 2016 at 16:4 Comment(0)
L
1

If you wish to do it from a Jenkins groovy file, you could use:

    def downloadSpec = """{
            "files": [
                {
                    "pattern": pattern,
                    "target": "",
                    "flat" : "true",
                    "sortBy": ["name"],
                    "sortOrder": "desc",
                    "limit": 1
                }
            ]
        }"""
Leucoma answered 22/9, 2020 at 11:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.