我正在尝试从我当地的Nexus repo下载最新/最新资产(JAR)。我正在使用Nexus Swagger UI。它有一个GET方法可供下载,
GET /beta/search/assets/download
问题是..我在repo中有很多资产,它会出错,
Search returned multiple assets, please refine search criteria to find a single asset
如何优化我的搜索&获取最新/最新的JAR?
仅供参考。目前,我在回购中拥有20多个资产,下面我展示其中两个......
{
"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
}
答案 0 :(得分:2)
您可以使用工件redirtect(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
您可以从那里提取最新的标签。
答案 1 :(得分:0)
在v3(确切地说是3.17.0)中使用REST API,以下方法应该可以获取任何lib的最新版本:
/service/rest/v1/search/assets/download?sort=version&maven.artifactId=artifactId&maven.groupId=groupId&maven.extension=jar