10

Nexus 2.x had a REST API to download artifacts like below but no longer works for Nexus 3.x

wget "http://local:8081/service/local/artifact/maven/redirect?g=com.mycompany&a=my-app&v=LATEST" --content-disposition

Has the API changed to something else for on Nexus 3.0.0-03?

DarVar
  • 16,882
  • 29
  • 97
  • 146

5 Answers5

5

Currently this does not exist in Nexus 3. It is on our Roadmap.

Edit: Since Nexus 3.3 API functionality has been added. See https://help.sonatype.com/repomanager3/rest-and-integration-api for more information.

Bertware
  • 297
  • 8
  • 16
DarthHater
  • 3,222
  • 25
  • 26
2

The URL for downloading a Maven asset directly with Nexus3 looks roughly like this:

https://nexus.example.local/service/rest/v1/search/assets/download?sort=version&repository=snapshots&maven.groupId=com.example.group&maven.artifactId=my-artifact&maven.baseVersion=1.0.0-SNAPSHOT&maven.extension=jar

(Tested with Nexus v3.28)

For more options and other repository formats, check out the Swagger interface that's available in the administration area of Nexus.

philippn
  • 1,850
  • 1
  • 14
  • 11
1

At this time, the REST API has been released as beta. You can get more information and give us feedback by going to this link: http://blog.sonatype.com/nexus-repository-new-beta-rest-api-for-content

DarthHater
  • 3,222
  • 25
  • 26
  • 1
    with maven repository, the search API works perfectly for hosted repository but not with proxy and group repository. – Maoz Zadok Jan 30 '18 at 06:56
1

just for this case, I created a PHP script that returns HTTP redirect to the location of the artifact. feel free to use https://github.com/maozza/nexus3-redirector

Maoz Zadok
  • 4,871
  • 3
  • 33
  • 43
0

None of the existing answers worked for me - all of them return 404. I have a proxy repository configured in Nexus OSS 3.38. The URL that successfully cached and downloaded the artifact was as follows (but it requires a specific version to be known):

https://<nexus-url>/repository/<repo-name>/<group/as/slashes>/<artifact>/<version>/<artifact>-<version>.<format>

for example slf4j-api:

https://nexus.url/repository/maven-proxy/org/slf4j/slf4j-api/2.0.7/slf4j-api-2.0.7.jar

Hope this helps someone.

piomar123
  • 70
  • 2
  • 8