OSS Nexus:如何使用REST API将最新版本作为文本检索

few*_*ewe 7 rest timestamp nexus

我想检索最新的版本名称(作为文本),以便能够重命名从Nexus检索到的具有时间戳的艺术品.

我所做的是创建包含内部jar项目,依赖项,相关脚本的几个档案的存档......但是如果打包的jar是快照,则存档在下载时会以时间戳结束.这些时间戳取代了存档的XXX-SNAPSHOT扩展名,我无法使任何自动脚本执行某些任务,如提取存档,重命名目录,制作一些符号链接,......

我没有在其余的api文档中找到与此相关的任何内容.有没有一个简单的方法来执行其余的api或某种脚本?

谢谢.

编辑:

从下面的答案我设法使用LATEST而不是版本名称检索最新的快照版本:

然后使用脚本我可以检索基本版本.

#!/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"
Run Code Online (Sandbox Code Playgroud)

谢谢!

Mar*_*nor 8

Nexus具有以下REST API,用于描述如何解析Maven模块:

要获取有关以下工件的详细信息:

<groupId>org.cometd.jetty</groupId>
<artifactId>cometd-jetty-client</artifactId>
<version>1.0-SNAPSHOT</version>
Run Code Online (Sandbox Code Playgroud)

使用以下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

返回以下报告:

<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>
Run Code Online (Sandbox Code Playgroud)