Is it possible to export users from nexus repository using curl command. Users are only command

Viewed 12

I am trying to export in file the list of users from nexus. But I am only getting the format not the list of users "curl -k -X GET https://<repository_url>/#admin/security/users "

1 Answers

You can use the rest api provided by nexus server

Swagger file

http://localhost:8081/service/rest/swagger.json

Users endpoint

curl http://localhost:8081/service/rest/v1/security/users -u user:password

Response

[ {
  "userId" : "anonymous",
  "firstName" : "Anonymous",
  "lastName" : "User",
  "emailAddress" : "anonymous@example.org",
  "source" : "default",
  "status" : "active",
  "readOnly" : false,
  "roles" : [ "nx-anonymous" ],
  "externalRoles" : [ ]
}, {
  "userId" : "admin",
  "firstName" : "Administrator",
  "lastName" : "User",
  "emailAddress" : "admin@example.org",
  "source" : "default",
  "status" : "active",
  "readOnly" : false,
  "roles" : [ "nx-admin" ],
  "externalRoles" : [ ]
} ]

And if you need to parse this json, use jq:

cat json | jq '.[].userId'

Result

"anonymous"
"admin"
Related