News and Notes from the Makers of Nexus | Sonatype Blog

Q&A Corner With the Nexus Support Team

Written by Mark Miller | December 08, 2017

The Nexus Support Team answers questions and suggests solutions on the Nexus User List. Each Friday, we look at solutions the community found of interest.

How to Create or Delete a Repository in Sonatype Nexus Repository OSS 3.2 From Command Prompt

Question: I'm a new user, started using the Sonatype Nexus Repository OSS 3.2. I would like to create or delete a repository outside the UI, from the command line. Any help would be appreciated.

Answer: You can write a groovy script that does these things, and execute it from the REST API interface.

--------------

Is There a Way to Get a List of All Users in Sonatype Nexus Repository 3?

Question: Is there a way to generate a report or other process to get a list of all systems or ldap users list in Sonatype Nexus Repository 3.2? We also have to get the list of users who used Nexus for 30 days.

Answer: Use the nexus request.log. The IP address used to access Nexus is in column one, the user ID (if any was provided) is in column 3. The user agent string used by the client is in the last column:

127.0.0.1 - admin [04/Dec/2017:11:52:47 -0600] "GET /service/extdirect/poll/rapture_State_get?_dc=1512409967622 HTTP/1.1" 200 20399 14 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36"

As an example, here is a single command you can use at a terminal to list all unique user names for request logs from Aug 2017.

gunzip -c request-2017-08*.log.gz | awk '{print $3}' | sort | uniq

--------------

Multiple Migrations Against the Same Sonatype Nexus Repository 2 Instance

Question: I have a Sonatype Nexus Repository OSS 2.14.5-02 instance, and plan to migrate it to a new 3.6.2 production instance, but I would like to do a dry run using a new 3.6.2 TEST instance first. My questions are:

1. Could I do multiple migrations against the same Sonatype Nexus Repository 2 instance, as long as my Sonatype Nexus Repository 3 instance is a new install each time? It looks like I could, but I would like to be sure.

2. If I could, is there anything special I need to do on the Nexus 2 instance before a second migration? Is removing sonatype-work/nexus/db/migrationagent necessary?

Answer: Yes, you can do multiple migrations. as long as each Sonatype Nexus Repository 3 instance is a new install (starting with a clean work directory). Before running a new migration, shut down Sonatype Nexus Repository 2 and remove "sonatype-work/nexus/db/migrationagent".

--------------

Do you have a question about using Sonatype Nexus Repository, Sonatype Lifecycle, or Sonatype Repository Firewall? Ask the Support Team on the Nexus User List.