title: OSS Nexus: how to use REST API to retrieve last version as a text
body: <p>I'd like to retrieve the latest version name (as text) to be able to rename the artificats retrieved from Nexus which have timestamps.</p>
  
  <p>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, ...</p>
  
  <p>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?</p>
  
  <p>Thanks.</p>
  
  <p>Edit:</p>
  
  <p>From the below answer I managed to retrieve the latest snapshot version using LATEST instead of the version name:</p>
  
  <p>Then using a script I can retrieve the base version.</p>
  
  <pre><code>#!/bin/bash
  VERSION=`curl --silent "http://redmine.saic.int:8081/nexus/service/local/artifact/maven/resolve?r=snapshots&amp;g=com.g2mobility&amp;a=G2-Modem-Mgr&amp;v=LATEST&amp;c=executable&amp;e=tar.gz" | sed -n 's|&lt;baseVersion&gt;\(.*\)&lt;/baseVersion&gt;|\1|p'`
  
  VERSION=`echo "$VERSION" | tr -d ' '`
  
  echo "Version is $VERSION"
  </code></pre>
  
  <p>Thanks!</p>