OSS Nexus:如何使用REST API检索文本的最新版本 [英] OSS Nexus: how to use REST API to retrieve last version as a text

查看:175
本文介绍了OSS Nexus:如何使用REST API检索文本的最新版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检索最新版本名称(以文本形式),以便能够重命名从Nexus检索到的带有时间戳的标记.

I'd like to retrieve the latest version name (as text) to be able to rename the artificats retrieved from Nexus which have timestamps.

我要做的是创建一个包含内部jar项目,依赖项,相关脚本等多个档案的档案,但是...如果打包的jar是快照,则档案在下载时会带有时间戳记.这些时间戳替换了档案的X.X.X-SNAPSHOT扩展名,我无法制作任何自动化脚本来执行某些任务,例如提取档案,重命名目录,进行一些符号链接,...

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, ...

我在rest api文档中没有找到与此相关的任何内容.有没有一种简单的方法可以使用其余的api或某种脚本执行此操作?

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?

谢谢.

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

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"

谢谢!

推荐答案

Nexus具有以下REST API,用于描述Maven模块的解析方式:

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>

使用以下REST API:

Use the following REST API:

返回以下报告:

<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>

这篇关于OSS Nexus:如何使用REST API检索文本的最新版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆