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?
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.
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
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
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.
Related
We are upgrading our nexus artifact repository from 2.x to 3.x version. During this process, after the migration is complete, there is a timestamp missing for the artifacts. Any solution regarding this will be helpful.
This has nothing to do with your upgrade. Tree view (browse) in Nexus Repository Manager 3 does not show last modified for folders. I have never heard this requested but if this is important to you, suggest you file a ticket in issues.sonatype.com in the NEXUS project and it can be evaluated by the team.
Is there any API or report to query and find all available versions in nexus for Docker, maven etc ?
You can use Nexus API to query/search, find an item in nexus.
The API url is like: Your_nexus_ur/swagger-ui/
On the Sonatype.com website I can read the following
Nexus is a repository manager. It allows you to proxy, collect, and
manage your dependencies so that you are not constantly juggling a
collection of JARs. It makes it easy to distribute your software.
Internally, you configure your build to publish artifacts to Nexus and
they then become available to other developers. You get the benefits
of having your own ‘central’, and there is no easier way to
collaborate.
The part about "constantly juggling a collection of JAR" I find intriguing.
I my experience, this is exactly what the Nexus process looks like.
As an example. My build is failing with message
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project myproject:jar:1.0.0-SNAPSHOT: Could not find artifact net.sf.saxon:saxon-dom:jar:9.0 in nexus (https://mynexus:8443/nexus/content/groups/public/)
So supposedly the Nexus repo at https://mynexus:8443/nexus/content/groups/public/ does not contain this artifact.
Using the Nexus web interface I can however search and find this particular artifact. It is located in the Jboss Maven2 repo.
What I can also do is navigate the index of the Public Repositories and find this particular artifact saxon-dom version 9.0 manually by expanding the tree navigator. It is in the folder net\sf\saxon.
So my conclusion is that Nexus is exactly not doing what it is claiming to be doing. It is not helping me manage dependencies - I have to resolve those manually.
What results is exactly like constantly juggling collections of jars. I have to manually download those and put them on the class path in order to perform a build.
As a Repository Manager it does not look very useful.
As it turns out, I needed to wrap my brain around the way that Nexus deals with missing dependencies.
This issue I think that artifact saxon-dom was once part of the repo but removed at some point. See https://repository.jboss.org/nexus/content/groups/public/net/sf/saxon/saxon-dom/
So there still is some metadata but not the jar and the pom.
When I search for the artifact Nexus finds it based on this metadata. In search results I can see the jar and pom.
Now I mistakenly thought that the artifacts are found and in the repo. This is not the case because if we try to download the jar you see message similar to below.
So Nexus caches the 404, the fact that it was unable to find the artifact. But it is completely unclear in the UI that the result is a cached 404.
In previous versions of Nexus you could look at the output of http:///nexus/service/local/status and this would give you a list of installed plugins.
However, in Nexus 2.7 that functionality is no longer present. Has this been moved to a new location or is there another way of accessing it.
I realize that it can be viewed in the Plugin Console from the UI but this is for automation purpose so manual checks won't work.
The following REST API will return a list of plugins and links to other API docs:
Nexus Plugin Console Plugin REST API
Example URL:
http://localhost:8081/nexus/service/local/plugin_console/plugin_infos
So it seems that giving Nexus a version of "LATEST" will tell it to redirect to latest version of the specified build product.
Where in the docs is this actually documented?
The FAQ contains detailed explanation:
https://docs.sonatype.com/display/SPRTNXOSS/Nexus+FAQ#NexusFAQ-Q.HowcanIretrieveasnapshotifIdon%27tknowtheexactfilename%3F
But also the REST API doco (bundled with every Nexus instance) contains it too. Just login as Admin, go to Administration, Plugin Console, select Core Documentation plugin in grid, and client on the "Core API" link on lower panel.