0
votes

Problem:

I'm trying to figure out if it is possible to download the latest binary from an artifactory repo. I'd like to use the Created property of the file if possible.

Attempt:

I can successfully download files via the rtDownload plugin


rtDownload (
    serverId: 'Artifactory-1',
    // Build name and build number for the build-info:
    buildName: 'holyFrog',
    buildNumber: '42',
    // You also have the option of customising the build-info module name:
    module: 'my-custom-build-info-module-name',
    specPath: 'path/to/spec/relative/to/workspace/spec.json'
)

I would like to see if I can use a combination of limit and sortOrder to download the latest binary from a repo. It's not clear to me as to how I can achieve that based on the documentation: https://www.jfrog.com/confluence/display/JFROG/Using+File+Specs. Any help would be greatly appreciated!

Update: I can't use the build-name like this: Jenkins Artifactory plugin - grabbing latest artifacts

I found out that the cli supports "sortBy": ["created"], but the pipeline doesn't: https://www.jfrog.com/jira/browse/HAP-1215. Anyone find a workaround for this?

2

2 Answers

0
votes

Please upgrade the Jenkins Artifactory plugin to 3.5.0 (https://www.jfrog.com/confluence/display/JFROG/Jenkins+Artifactory+Plug-in#JenkinsArtifactoryPlug-in-ReleaseNotes)and let me know if you are able to sort using the same Jenkins Pipeline

0
votes

After some source diving, I found the FileSpec class which each element in the spec is mapped to. Based on this, the sortBy, sortOrder, and limit fields should be part of the file object, not the aql object. For example:

{
  "files": [
    "aql": {
      "repo": "my-repo",
      "path": "my/artifacts/path"
    },
    "sortBy": ["created", "name"],
    "sortOrder": "desc",
    "limit": 1,
    "target": "artifacts"
  ]
}