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!
The documentation for the Maven Resolve Nexus REST API can be found here: https://maven.java.net/nexus-core-documentation-plugin/core/docs/rest.artifact.maven.resolve.html
This was an eariler deleted posting proposing an alternative way of assembling distributions from Maven repository content:
Ivy is an alternative dependency management client, which can be run from the command-line as follows:
The retrieve option of the ivy command details how the downloaded files should be stored locally:
The correct timestamped artifact is retrieved but the "SNAPSHOT" revision number is preserved, which is what I understand you're trying to do.
The ivysettings file details the repositories to be used when downloading artifacts:
Nexus has the following REST API for describing how Maven modules are resolved:
Example
To obtain the details about the following artifact:
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: