gpt4 book ai didi

maven - 从 Nexus3 下载单个/最新 Assets (JAR)

转载 作者:行者123 更新时间:2023-12-03 22:42:40 26 4
gpt4 key购买 nike

我正在尝试从我的本地 Nexus 存储库下载最新/最新的 Assets (JAR)。我正在使用 Nexus Swagger UI。它有一个 GET 方法来下载,

GET /beta/search/assets/download

问题是..我在 repo 中有很多 Assets ,它给出了错误,
Search returned multiple assets, please refine search criteria to find a single asset

如何优化我的搜索并获取最新/最新的 JAR?

enter image description here

仅供引用..目前,我在 repo 中有 20 多个 Assets ,下面我展示了其中的两个..
{
"items": [
{
"downloadUrl": "http://localhost:8081/repository/snapshot/com/openshift/test/openshift-jenkins/0.0.1-SNAPSHOT/openshift-jenkins-0.0.1-20180214.211251-17.jar",
"path": "com/openshift/test/openshift-jenkins/0.0.1-SNAPSHOT/openshift-jenkins-0.0.1-20180214.211251-17.jar",
"id": "c25hcHNob3Q6ZTAxODhlZDA3MjhmYTY4ZmIwOGZkYzAyYTliZTQ4Zjg",
"repository": "snapshot",
"format": "maven2",
"checksum": {
"sha1": "53cdfcf964d0edd5fc6fdefa457e700eff47a1ca",
"md5": "d0c82971b82957728d0b4c858150d56c"
}
},
{
"downloadUrl": "http://localhost:8081/repository/snapshot/com/openshift/test/openshift-jenkins/0.0.1-SNAPSHOT/openshift-jenkins-0.0.1-20180214.210246-15.jar",
"path": "com/openshift/test/openshift-jenkins/0.0.1-SNAPSHOT/openshift-jenkins-0.0.1-20180214.210246-15.jar",
"id": "c25hcHNob3Q6MjEwMzFkZmFmNDVlNWI1ODgwZTUwYjE5M2Y5NGVkNjk",
"repository": "snapshot",
"format": "maven2",
"checksum": {
"sha1": "b041f4b1e6bcb81366a72635f6c576ae46a83ec8",
"md5": "af970e3e66c9cd20ff66f1074da04c21"
}
}
],
"continuationToken": null
}

最佳答案

您可以不使用搜索,而是使用 Artifact 重定向(使用 curl -L 可以跟踪重定向): /artifact/maven/redirect

curl -L "http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=log4j&a=log4j&v=LATEST" -o log4j.jar

然而,它 might not be available for Nexus 3 yet .

在这种情况下,您需要 download and parse first the maven-metadata.xml .
您可以从那里提取最新的标签。

2018 年 2 月, NEXUS-12469问了同样的问题,并引用了 NEXUS-14407 :REST 搜索和下载由“最新”发布,于 2019 年第四季度 3.16 发布。

Extend the search & download service so that users can sort the search results by 'latest version'.



Examples :
http://localhost:8081/service/rest/v1/search/assets/download?repository=maven-central&group=junit&name=junit&sort=version&prerelease=false

curl -L -o myartifact.tar.gz -u xxx:xxx "http://localhost:8080/service/rest/v1/search/assets/download?sort=version&direction=desc&repository=maven-snapshots&maven.groupId=bla.bla.bla&maven.artifactId=bla-bla&maven.extension=tar.gz

所以组合:
  • API 端点 assets/download
  • sort=version修饰符
  • 关于maven - 从 Nexus3 下载单个/最新 Assets (JAR),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48796533/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com