Package: nexus3-cli
nexus3-cliA python-based command-line interface and API client for Sonatype'sNexus
OSS 3.FeaturesCompatible withNexus 3 OSSNexus versions testedPython API and command-line support.Artefact management: list, delete, bulk upload and download.Repository management:Create hosted and proxy.Create apt, bower, docker, maven, npm, nuget, pypi, raw, rubygems, yum.Content type validation, version and write policy.Delete.Groovy script management: list, upload, delete, run.Clean-up policy management: create, list.Task management: list, run, show stop.Security management: realms.Blob store management: list, show, create, delete, update (API only).The actions above are performed using the Nexus REST API if the endpoint is
available, otherwise a groovy script is used.Please note that some Nexus 3 features are not currently supported. Assistance
implementing missing support is very welcome. Please have a look at theissuesandcontribution guidelines.InstallationThe nexus3-cli package is available on PyPi. You can install using pip/pip3:pipinstallnexus3-cliThere's also adocker image with nexus3-cli
pre-installed.Enable Groovy scriptsSome of the functionality in this client was written before the Nexus REST API
exposed the necessary endpoints. For this reason, you may need to enable Groovy
script execution in your instance.See theFAQ in this blog postand theexamplenexus.propertiesin this project.If you decide to leave groovy scripts disabled in your Nexus 3 instance, you need to disable its
use in this client. This can be done by editing the~/.nexus-cliconfiguration and changinggroovy_enabledtofalse. Alternatively, you can export theNEXUS3_GROOVY_ENABLED=falseenvironment variable.UsageCommand lineFor a quick start, use thesonatype/nexus3 Docker image:dockerrun-d--rm-p127.0.0.1:8081:8081--namenexussonatype/nexus3Nexus will take a little while to start-up the first time you run it. You can
tell when it's available by looking at the Docker instance logs or browsing tohttp://localhost:8081.On older versions of the nexus3 Docker image, the defaultadminpassword isadmin123; on newer versions it's automatically generated and you can find it
by runningdocker exec nexus cat /nexus-data/admin.password.Thelogincommand will store the service URL and your credentials in~/.nexus-cli(warning: restrictive file permissions are set but the contents
are saved in plain-text).Setup CLI credentials:$nexus3login
NexusOSSURL(http://localhost:8081):
Nexusadminusername(admin):
Nexusadminpassword(admin123):
Verifyservercertificate(True):

Configurationsavedto/Users/thiago/.nexus-cliList repositories:$nexus3repositorylist
NameFormatTypeURL
maven-snapshotsmaven2hostedhttp://localhost:8081/repository/maven-snapshots
maven-centralmaven2proxyhttp://localhost:8081/repository/maven-central
nuget-groupnugetgrouphttp://localhost:8081/repository/nuget-group
nuget.org-proxynugetproxyhttp://localhost:8081/repository/nuget.org-proxy
maven-releasesmaven2hostedhttp://localhost:8081/repository/maven-releases
nuget-hostednugethostedhttp://localhost:8081/repository/nuget-hosted
maven-publicmaven2grouphttp://localhost:8081/repository/maven-publicCreate a repository:nexus3repositorycreatehostedrawreponameDo a recursive directory upload:$mkdir-p/tmp/some/deep/test/path
$touch/tmp/some/deep/test/file.txt/tmp/some/deep/test/path/other.txt
$cd/tmp;nexus3upsome/reponame/path/
Uploadingsome/toreponame/path/[################################] 2/2 - 00:00:00Uploaded2filestoreponame/path/Nota Bene: nexus3-cli interprets a path ending in/as a directory.List repository contents:$nexus3lsreponame/path/
path/some/deep/test/path/other.txt
path/some/deep/test/file.txtFor all commands, subcommands and options, runnexus3 -h.CLI documentationAPISeeAPI documentation.DevelopmentThe automated tests are configured in.gitlab-ci.yml. To run tests locally,
install the package with test dependencies and run pytest:pipinstall[--user]-e.[test]pipinstall[--user]pytestfaker
pytest-m'not integration'Integration tests require a local Nexus instance listening on 8081 or as
configured in~/.nexus-cli. The configuration file can be created usingnexus3 login.dockerrun-d--rm-p127.0.0.1:8081:8081--namenexussonatype/nexus3
./tests/wait-for-nexus.sh# the Nexus instance takes a while to be ready# use the random admin password generated by the Nexus container to login./tests/nexus-login$(dockerexecnexuscat/nexus-data/admin.password)pytest-mintegration
dockerkillnexusNota Bene: if you re-run integration tests without re-creating or cleaning-up the
dev Nexus instance, test will fail because some objects created during tests will
already exist.Pull requests are welcome; please seeCONTRIBUTING.md.