Skip to main content

A CLI tool for managing Sonatype Nexus3 via its REST API

Project description

nexus3-tool

PyPI version Python Versions License: MIT Publish to PyPI

A command-line tool for managing Sonatype Nexus3 via its REST API, following a familiar docker-style command pattern.


Installation

pip install nexus3-tool

Usage

nexus3-tool [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  login                Authenticate with a Nexus3 instance.
  list-docker-repos    List all Docker repositories.
  list-docker-images   List images and tags in a Docker repository.
  prune-docker-images  Prune old tags from a Docker image.

login

Authenticate with your Nexus3 instance. Credentials (including SSL preference) are stored in ~/.nexus-credentials and reused by all subsequent commands.

Interactive (default) — prompts for username and password:

nexus3-tool login https://nexus.example.com

If the server uses an internal or self-signed certificate, the tool will detect the SSL failure and prompt you to disable verification — no flags required.

Non-interactive — for use in CI/CD pipelines:

nexus3-tool login https://nexus.example.com --username admin --password secret

# With an internal/self-signed certificate:
nexus3-tool login https://nexus.example.com --username admin --password secret --ignore-untrusted-certs

list-docker-repos

List all Docker-format repositories and their type (hosted, proxy, group).

nexus3-tool list-docker-repos

list-docker-images

List all images and tags in a repository, with their publish date.

# List all images in a repo
nexus3-tool list-docker-images development

# Filter to a specific image (faster — server-side filtering)
nexus3-tool list-docker-images development --image-name myapp

prune-docker-images

Remove old tags from a Docker image, keeping the most recent. The latest tag is always preserved and is not counted against --keep-last.

# Preview what would be deleted (no changes made)
nexus3-tool prune-docker-images production --image-name myapp --dry-run

# Keep the 5 most recent tags (default), prompt for confirmation
nexus3-tool prune-docker-images production --image-name myapp --keep-last 5

# Keep the 10 most recent tags, skip confirmation prompt
nexus3-tool prune-docker-images production --image-name myapp --keep-last 10 --yes

Tags are sorted by last-modified date. If latest is an alias for a versioned tag, both are annotated in the output so you can see exactly what is being kept.

Note: Deleting tags removes the component from Nexus, but physical disk space is only reclaimed when a Nexus admin runs the "Delete unused manifest and unreferenced blobs" and "Compact blob store" tasks.


Development

Clone the repository and install in editable mode:

git clone https://github.com/tkdpython/nexus3-tool.git
cd nexus3-tool
pip install -e .

You can also run any command directly without installing:

python3 -m nexus3_tool login https://nexus.example.com
python3 -m nexus3_tool list-docker-repos
python3 -m nexus3_tool list-docker-images development --image-name myapp
python3 -m nexus3_tool prune-docker-images production --image-name myapp --dry-run

Publishing a Release

Releases are published to PyPI automatically via GitHub Actions when a version tag is pushed:

git tag v0.3.0
git push origin v0.3.0

The workflow uses PyPI Trusted Publishers (OIDC) — no API token secrets required. You must configure a Trusted Publisher on PyPI for this repository first.

PyPI Trusted Publisher Setup

  1. Log in to pypi.org and navigate to your project.
  2. Go to Manage → Publishing and add a new Trusted Publisher:
    • Owner: tkdpython
    • Repository: nexus3-tool
    • Workflow filename: publish.yml
    • Environment name: release
  3. On GitHub, create an Environment named release under Settings → Environments.

License

MIT © tkdpython


Installation

pip install nexus3-tool

Usage

nexus3-tool [OPTIONS] COMMAND [ARGS]...

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  login              Authenticate with a Nexus3 instance.
  prune-docker-repo  Prune old tags from a Nexus3 Docker repository.

Login

Authenticate with your Nexus3 instance. Credentials will be stored in ~/.nexus-credentials for use by subsequent commands.

nexus3-tool login https://nexus.example.com

Prune Docker Repository

Remove old image tags from a hosted Docker repository, keeping only the most recent.

# Keep the 5 most recent tags (default)
nexus3-tool prune-docker-repo my-app

# Keep the 10 most recent tags
nexus3-tool prune-docker-repo my-app --keep-last=10

Planned Features

  • nexus3-tool login <url> — Authenticate and store credentials in ~/.nexus-credentials
  • nexus3-tool prune-docker-repo <image> --keep-last=<n> — Prune old Docker image tags

Development

Clone the repository and install in editable mode:

git clone https://github.com/tkdpython/nexus3-tool.git
cd nexus3-tool
pip install -e ".[dev]"

Publishing a Release

Releases are published to PyPI automatically via GitHub Actions when a version tag is pushed:

git tag v0.1.0
git push origin v0.1.0

The workflow uses PyPI Trusted Publishers (OIDC) — no API token secrets required.
You must configure a Trusted Publisher on PyPI for this repository first. See the setup guide below.

PyPI Trusted Publisher Setup

  1. Log in to pypi.org and navigate to your project (or create it via the first manual publish).
  2. Go to Manage → Publishing and add a new Trusted Publisher:
    • Owner: tkdpython
    • Repository: nexus3-tool
    • Workflow filename: publish.yml
    • Environment name: release
  3. On GitHub, create a Environment named release under Settings → Environments (optional but recommended for approval gates).

License

MIT © tkdpython

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus3_tool-0.4.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus3_tool-0.4.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file nexus3_tool-0.4.0.tar.gz.

File metadata

  • Download URL: nexus3_tool-0.4.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexus3_tool-0.4.0.tar.gz
Algorithm Hash digest
SHA256 96cf9cb405790a3bb3dbfb908b3cd04778c7049ac6634adb7a4186c176c3800f
MD5 716239aaf7c99e07120d7eb77c850862
BLAKE2b-256 c1963d81d6617caa3e7fa1bf4334ddff5c6ba674ff788d477d955098263e0b86

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexus3_tool-0.4.0.tar.gz:

Publisher: publish.yml on tkdpython/nexus3-tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nexus3_tool-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: nexus3_tool-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nexus3_tool-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d92735ff01ea2f7502ac97f3901a8e39c878032c7be95e52f0f707aca32217b9
MD5 2b42676264e0ca7638daa5983d0a343a
BLAKE2b-256 a0790d69abbf88a45251d634cc964132792a8f39373bcd69b267058f20411e22

See more details on using hashes here.

Provenance

The following attestation bundles were made for nexus3_tool-0.4.0-py3-none-any.whl:

Publisher: publish.yml on tkdpython/nexus3-tool

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page