How to search for a dependency in nexus repository manager via API? - spring

I have all the repository being listed in the nexus. I want an API which I can can use to search for a specific dependency in that nexus. For ex- If i want 'ojdbc' dependency then I should just provide the 'ojdbc' and the api should search within nexus and returns me the list of dependency which contains info like groupId, artifactId and version (and multiple if there are multiple matches).
Also, can i modify the same query to filter using user provided groupId, artifactId and version?

I came to know about the REST api offered by Nexus which can be used to search an asset and even fetch that asset.
Please go through - https://help.sonatype.com/repomanager3/rest-and-integration-api
Searching an asset or component - https://help.sonatype.com/repomanager3/rest-and-integration-api/search-api

Related

How to merge "archetype-catalog.xml" from different repositories into a single Maven group repository In nexus3

I'm trying to aggregate archetypes from multiple releases repositories into a single "maven-public" distribution group in an internal nexus.
All the archetypes are available to download in the group repository but it looks like is not compiling an aggregated version of the catalogs, the catalog it serves is the one from the first repository of the group.
Is this doable? All the examples I see around retrieve the catalog from the releases repository directly.
Any help is greatly appreciated.
After checking all member repositories of the maven group I found out that one of the proxy repositories had an invalid catalog and it was messing up the merge of the rest of catalogs.
Removing that repository from the group fixed the problem.

adding metadata to artifactory

The problem:
I need to be able to use artifacts/versions that passed specific version CI of 3 different project.
For instance project A version x.y.z passed the pipeline with B version x2.y2.z2 and when building C I need to be able to get the artifact of A and B that passed a specific versions.
Therefore I was thinking of pushing additional metadata to the stored artifact in artifactory and when building C to query the artifactory with the data.
How can I add custom data to artifact stored in artifactory as per the CI pipeline with Jenkins
You can use Artifactory's REST api or the JFrog CLI to easily set properties on an Artifact or an entire Folder.
You can then query Items/Artifacts based on the properties using REST
or CLI using a spec file
for more advanced querying capabilities you can use Artifactory's AQL
Use Maven Artifactory Plugin
https://www.jfrog.com/confluence/display/RTF/Maven+Artifactory+Plugin
to specify custom metadata for the deployment.

Maven Nexus: add group repository only with artifacts with prefix xxx.yyy

I wonder if it's possible to define a Group Repository in Maven Nexus and tell it to get the artifacts from existing repositories, but only those with ID matching a certain prefix xxx.yyy
This way, not all the artifacts of a repository will be available at this group repository, but only those I want to publish.
If you are using Nexus 2.x professional, you can use procurement to define a restricted view on a repository, allowing only artifacts that fulfil certain rules. Your intended rule should be among the possible ones.

1.0.0-SNAPSHOT in two Nexus repositories of one group

Say I have a "public" group in Nexus which contains two repositories "snapshotsA" and "snapshotsB". Both contain versions with the same Maven coordinates, like com.something:artifact:1.0.0-SNAPSHOT. How does Nexus resolve a SNAPSHOT reference? Does it look into both repositories to find the latest element? Or is it satisfied after finding the first one?
For groups in Nexus Repository 2.x, we resolve the first match in the group ordering, unless some sort of Repository Routing or Repository Target rules prevent that from being matched (for example if you know bad versions of that component exist in that repository by not treating components immutably, etc...)
In Nexus Repository 3.x this is currently simpler as we have not implemented Repository Routing. The first match in the group ordering is what you would get back.
Group repositories serve a list of repositories under the same URL. They fetch the maven-metadata.xml files from all the repositories they serve and create a merged representation of them. They also have a Lucene index via the maven-indexer (which is a library contributed as OSS by Sonatype to Apache that allows a repository manager, or tool, such as an IDE, to work with this index of artifacts contained in the repository). The index of group repositories is also a merged representation of the indexes of each of the repositories in the group.
As far as I'm aware, for Nexus 2.x, the file system is the first place to try and, if it fails, the Lucene index is queried in order to resolve from the respective proxy repository's remote host.

Dynamically Link To Latest 'jar-with-dependencies' From Maven Central

I'm trying to use the Maven central API to provide dynamic download links for the latest versions of an artifact. While this works for a normal jar, I cannot seem to get it to link to the 'jar-with-dependencies' version of the artifact.
Using the com.ning:nagios artifact, the latest can be downloaded at
http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.ning&a=nagios&v=LATEST
I had assumed that I could use the l query param (based on the linked API) to specify the 'jar-with-dependencies' classifier but the link only downloads the normal jar.
http://repository.sonatype.org/service/local/artifact/maven/redirect?r=central-proxy&g=com.ning&a=nagios&v=LATEST&l=jar-with-dependencies
Is there any way to link to this version of the artifact?
It turns out the classifier parameter is 'c' for the redirecting download service, not 'l' as used in the Solr API (in that API 'c' is for 'classname') - so this will work:
https://search.maven.org/remote_content?g=com.ning&a=nagios&v=LATEST&c=jar-with-dependencies
(note, updated after Sonatype put BASIC auth on the old url - we use this new official download url on maven.org instead now)
It downloads the 1.2MB jar that includes dependencies (not the regular jar) - currently the latest version is nagios-0.0.2-jar-with-dependencies.jar.

Resources