如何从 Nexus OSS 3.0 检索最新的快照

Howto retrieve the latest Snapshot from Nexus OSS 3.0

我们目前使用的是 Nexus OSS 3.0.0-03,我需要通过控制台检索最新的快照(或快照名称)。

其他不同帖子中提到的 Rest-API (.../service/local/artifact/maven/... ) 在 Nexus OSS 3.x 中不再可用(我得到 404 不找到)

https://books.sonatype.com/nexus-book/3.0/reference/scripting.html#_writing_scripts it is possible to write "own" Rest Calls but I found no documentation how to write them (No API-Doc, no example in https://github.com/sonatype/nexus-book-examples/tree/nexus-3.0.x)

所述

有谁知道是否可以以及如何检索快照名称

目前没有 REST API 或支持的内部 API 来计算最新的 SNAPSHOT 版本。

虽然我不推荐它,但在依赖插件中有一个目标 get。结合“--update-snapshots”标志在您的场景中应该可以正常工作。

我使用 Groovy Grapes:

用一个小 Groovy-Script 解决了这个问题
@GrabResolver(name = 'my-SNAPSHOT', root = 'http://mynexus:8081/repository/Snapshot-Repo/', m2Compatible = 'true')
@Grab('commons-io:commons-io:1.2')
import org.apache.commons.io.*


public class exec {
    public static void main(String[] args) {
        try {
            def g = groovy.grape.Grape.grab(group: "com.x.x.x", module: args[0], version: args[1], ext: 'zip')
            def depfile = groovy.grape.Grape.resolve([:], [group: "com.x.x.x", module: args[0], version: args[1], ext: 'zip'])[0]
            def workingFile = new File("release.zip");
            FileUtils.copyFile(new File(depfile), workingFile)
        } catch(Exception e){
            println e
        }
    }
}