I'd like to retrieve the latest version name (as text) to be able to rename the artificats retrieved from Nexus which have timestamps.
What I do is create an archive of several archives containing in-house jar projects, dependencies, related scripts, ... But if the packaged jars are snapshots, the archives end up with timestamps when downloaded. Those timestamps replace the X.X.X-SNAPSHOT extension of the archive and I cannot make any automated script to perform some tasks like extracting the archive, renaming the directory, make some symbolic links, ...
I did not find anything related to this in the rest api documentation. Is there a simple way to do this with the rest api or some kind of scripting?
Thanks.
Edit:
From the below answer I managed to retrieve the latest snapshot version using LATEST instead of the version name:
Then using a script I can retrieve the base version.
#!/bin/bash
VERSION=`curl --silent "http://redmine.saic.int:8081/nexus/service/local/artifact/maven/resolve?r=snapshots&g=com.g2mobility&a=G2-Modem-Mgr&v=LATEST&c=executable&e=tar.gz" | sed -n 's|<baseVersion>\(.*\)</baseVersion>|\1|p'`
VERSION=`echo "$VERSION" | tr -d ' '`
echo "Version is $VERSION"
Thanks!
Nexus Repository leverages Open API to document the REST API. To make it easier to consume, we ship Nexus Repository with Swagger UI - a simple, interactive user interface, where parameters can be filled out and REST calls made directly through the UI to see the results in the browser.
The Nexus Mods Public API allows third-party applications to access the Nexus Mods database, provided they are supplying a valid API Key for a user. Users can view their own API Keys by visiting https://www.nexusmods.com/users/myaccount?tab=api%20access.
Nexus has the following REST API for describing how Maven modules are resolved:
To obtain the details about the following artifact:
<groupId>org.cometd.jetty</groupId>
<artifactId>cometd-jetty-client</artifactId>
<version>1.0-SNAPSHOT</version>
Use the following REST API:
https://oss.sonatype.org/service/local/artifact/maven/resolve?r=cometd-snapshots&g=org.cometd.jetty&a=cometd-jetty-client&v=1.0-SNAPSHOT&e=jar
Returns the following report:
<artifact-resolution>
<data>
<presentLocally>true</presentLocally>
<groupId>org.cometd.jetty</groupId>
<artifactId>cometd-jetty-client</artifactId>
<version>1.0-20090313.100344-2</version>
<baseVersion>1.0-SNAPSHOT</baseVersion>
<extension>jar</extension>
<snapshot>true</snapshot>
<snapshotBuildNumber>2</snapshotBuildNumber>
<snapshotTimeStamp>1236938624000</snapshotTimeStamp>
<sha1>0cbf7163f19bf4586e27632a1f742dd0c0e0036d</sha1>
<repositoryPath>/org/cometd/jetty/cometd-jetty-client/1.0-SNAPSHOT/cometd-jetty-client-1.0-20090313.100344-2.jar</repositoryPath>
</data>
</artifact-resolution>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With