Unable to get latest version when using api - Sonatype Nexus Repository - Sonatype Community
Unable to get latest version when using api
post by mdaniel1 on Jan 13, 2022
I am trying to use the download API to get the latest version of a release but it looks like the artifact that I am getting is the first on the list and not the latest. Nexus version is OSS 3.25.1-04.
curl -v -X GET "http://localhost/service/rest/v1/search/assets/download?sort=version&repository=maven-releases&group=com.test&name=demo" -H "accept: application/json" -H "Authorization: Basic ***********"
According to the doc ( Search API), it should retrieve the latest. Does anyone encountered the same issue?
post by mpiggott on Jan 13, 2022
You should specify the direction of the sort.
post by mdaniel1 on Jan 13, 2022
Hey thanks, but according to the doc it should already retrieve the latest.
You can download the latest version of an asset by using the “sort=version”
Anyway, I tried many formats [sort=+-version, sort=version±, sort=version&direction=desc etc…] and none of them worked. Do you know what is the correct format? Thanks in advance!
post by wouter.van.toledo on Mar 23, 2022
We are running version 3.38.0-01 and using the search API we get another version on each request. It looks like it is paging the versions and returning the next on each request.
Is there a variable to only and always return the latest snapshot version? Thanks.
post by bierman.bob on Jun 6, 2022
We too are having problems with this. Ditto Wouter’s version, we are also on v3.38.0-01 and I have also tried all the combinations of path params that Daniel mentioned with no success. It always pulls the first version built.
I recall seeing a bug report that this had been fixed in an earlier version, but it appears to have crept back in? Any chance you can help us with this? It has caused some lost effort in determining that our deployment process had pulled the oldest version and not the newest. Appreciate any insight.
post by benjamin.sailer on Jun 24, 2022
Agree with Bob, I have the same problem, also for Sonatype Nexus Repository Manager OSS 3.38.0-01.
Probably this is the report on the earlier issue NEXUS-24601 Search API sorting doesn't work - Sonatype JIRA (found 3.25, fixed in 3.26).
In our test example, we had a bunch of 16 snapshot versions of the same artifact (all of them generated within one day). My observation (with simply sort=version as mentioned in the API for getting the latest version) called in a loop most of the time (18 out of 20 times) gave the artifact #13 (not #16, as I would have needed). Once I got #11.
Any support on that is highly appreciated!