使用 wget/curl 命令从 Nexus Repository Manager OSS 3.30.0-01 下载最新的快照工件

问题描述

我在使用 wget /curl 从 Nexus Repository Manager OSS 3.30.0-01 下载最新快照版本时遇到困难

我面临的问题是,在 nexus 中,同一快照版本中存在多个版本的人工制品,并附加时间戳加 - 如下图所示的增量数字

enter image description here

enter image description here

enter image description here

那么如何在一个快照下从多个版本下载最新的快照版本?

目前,我必须明确指定如下所示的版本

wget http://$NEXUS_URL/repository/mfi-snapshots/com/mf/productService/1.0.9-SNAPSHOT/productService-1.0.9-20210329.141405-11.war

那么有什么办法可以下载最新版本,只要提一下快照版本就可以下载最新版本

 $NEXUS_URL: is the nexus URL 
mfi-snapshots: is the snapshot repo
com.mf: is the group 
productService is the artefact
1.0.9 SNAPSHOT the version of the artefact

我尝试使用nexus中定义的“/v1/search/assets/download”API(不知道如何使用它

http://$NEXUS_URL/service/rest/v1/search/assets/download?sort=version&direction=desc&q=war&repository=mfi-snapshots&group=com.mf&name=productService

给出了一个 json 输出,如

enter image description here

解决方法

我按照有关 sonatype 的帮助文章中提到的步骤操作,我得到了解决方案

https://help.sonatype.com/repomanager3/rest-and-integration-api/search-api#SearchAPI-DownloadingtheLatestVersionofanAsset

curl -L -o productService.war  -s -X GET "$NEXUS_HOST/service/rest/v1/search/assets/download?sort=version&repository=$NEXUS_SNAPSHOTS_REPO&maven.groupId=com.mf&maven.artifactId=productService&maven.baseVersion=$SNAPSHOT_VERSION&maven.extension=war" -H "accept: application/json"