Skip to content

Migrating from Nexus Repository ​

This page moves a Sonatype Nexus Repository 3 installation to BatleHub, one repository at a time, without a day on which every build breaks at once.

BatleHub cannot yet import the contents of a Nexus instance in one command — that is on the roadmap ("Seed a registry from an incumbent"). The migration below does not need it: proxy repositories are recreated against their original upstreams, hosted repositories are copied with each ecosystem's own publish client, and Nexus keeps serving until the last client has moved.

Concepts side by side ​

NexusBatleHubNotes
Repository /repository/<name>/Registry /proxy/<name>/…One [[registries]] block per repository. The path after <name> depends on the type — see each registry page.
proxy repositorymode = "proxy"Read-through cache; the default mode.
hosted repositorymode = "local"BatleHub is the source of truth; clients publish to it.
group repositorymode = "hybrid", or several upstreamsSee Groups.
Blob store[storage] backendFilesystem or S3; a registry picks a named backend with storage = "…". See Configuration § [storage].
Cleanup policy[registries.cache] evictionartifact_ttl_secs, idle_days, max_size_bytes, keep_latest_n — see Caching.
Remote authentication[registries.upstream_auth]basic, bearer or header — see Private upstreams.
Users, roles, LDAP/SAML realms[[auth]] providers (token, OIDC, Kubernetes, Actions OIDC)Groups come from the identity provider.
Privileges, content selectorsGrants on the instance, registry, namespace, package or versionSee Access control.
User tokenPersonal access tokenSee Getting a token.

Formats ​

Nexus formatBatleHub typeHosted equivalent
maven2mavenyes
npmnpmyes
pypipypiyes
nugetnuget (v3 protocol)yes
rubygemsrubygemsyes
gogoproxyyes
aptdebyes
yumrpmyes
condacondayes
cargocargoyes
composercomposeryes
rawgenericno — proxy only
docker, helm, r, conan, cocoapods, p2, bower, gitlfs——

The last row is not supported yet. Some of those formats are on the roadmap, and the list of supported types grows with each release:

  • helm — a chart repository (index.yaml + .tgz) is planned in RFC 0029 (Draft). OCI-based charts stay out of scope.
  • docker — not planned: the roadmap points to a dedicated OCI registry such as Harbor.
  • r, conan, cocoapods, p2, bower, gitlfs — not on the roadmap today; open an issue if you need one.

Until then, keep those repositories in Nexus, or move them to a dedicated tool, before planning to switch Nexus off.

A raw hosted repository has no home either: generic only mirrors an upstream file tree.

1. Take the inventory ​

The Nexus REST API lists every repository with its format, type and remote URL:

bash
curl -su admin "https://nexus.example.com/service/rest/v1/repositories" \
  | jq -r '.[] | [.name, .format, .type, (.attributes.proxy.remoteUrl // "")] | @tsv'

Sort the result into three piles — proxy, hosted, group — and cross out the formats of the last row of the table above. Each pile has its own step below.

2. Proxy repositories ​

Point the BatleHub registry at the original upstream, not at Nexus:

toml
[[registries]]
type      = "maven"
name      = "maven-central"
upstreams = ["https://repo1.maven.org/maven2"]

The cache starts empty and fills on the first request for each artifact. To avoid a slow first build, warm the packages you know you need:

toml
[registries.cache]
warm_packages = ["lodash", "react", "typescript@5.4.5"]
warm_latest_n = 3

When the upstream needs credentials Nexus used to hold (a vendor's private feed), move them to [registries.upstream_auth] — see Private upstreams.

3. Hosted repositories ​

A hosted repository holds the only copy of what your teams published. Its history is copied into a local registry before anyone publishes to BatleHub.

Do not bridge with hybrid and Nexus as upstream

A hybrid registry answers a package's version listing from its local versions alone as soon as it has one, and does not consult the upstream for that name. Publish foo@1.0.1 to a hybrid registry whose upstream is the Nexus repository holding foo@1.0.0, and npm, Maven, pip, NuGet, cargo and Go clients stop seeing 1.0.0. This is not how a Nexus group behaves: a group merges the versions of a package across its members.

Create the local registry ​

toml
[[registries]]
type = "npm"
name = "npm-internal"
mode = "local"

[registries.grants]
"role:user"        = ["releases:read", "releases:list"]
"group:*:engineer" = ["releases:publish"]

Copy the history ​

List the hosted repository's assets with the Nexus components API (it pages with continuationToken):

bash
repo=npm-hosted token=""
while :; do
  page=$(curl -su batlehub-reader \
    "https://nexus.example.com/service/rest/v1/components?repository=$repo${token:+&continuationToken=$token}")
  jq -r '.items[].assets[].downloadUrl' <<<"$page"
  token=$(jq -r '.continuationToken // empty' <<<"$page")
  [ -z "$token" ] && break
done > assets.txt

Download them (wget --user batlehub-reader --ask-password -i assets.txt), then publish each file with the ecosystem's own client, as you would any new version:

TypeRepublish with
mavenmvn deploy:deploy-file -Dfile=<jar> -DpomFile=<pom> -Durl=https://batlehub.example.com/proxy/<registry>/maven2/ -DrepositoryId=<server-id>
npmnpm publish <package>-<version>.tgz
pypitwine upload --repository-url https://batlehub.example.com/proxy/<registry>/legacy/ <files>
nugetdotnet nuget push <file>.nupkg --source <source>
rubygemsgem push <file>.gem --host https://batlehub.example.com/proxy/<registry>

Each registry page has the exact client configuration under Publishing. Every republish is an ordinary publish, so quotas, ownership and scans all apply.

Turn monotonic off while copying

A history is published oldest-first; a namespace with versioning.monotonic = true refuses that. Turn it on again afterwards — see Immutability and ordering.

Switch ​

  1. Make the Nexus repository read-only, so nothing is published there any more.
  2. Copy the versions published since the first copy.
  3. Move the publishers (CI jobs, distributionManagement, publishConfig) and the consumers to BatleHub — see Move the clients.

Groups ​

A Nexus group has no one-to-one equivalent. Pick the shape that matches what it contained:

  • One hosted and one proxy repository (the classic maven-public): a single hybrid registry, with the hosted history copied into it as in step 3 and the public upstream in upstreams. A name published locally is served from its local versions only; any other name falls through to the upstream.
  • Several proxy repositories: a single proxy registry with several upstreams. They are tried in order and the next one is used on a 404.
  • A credentialed upstream and a public one: upstream_auth is sent to every upstream of a registry, so split them — see Mixing a private upstream with a public fallback.

4. Move the clients ​

Replace the Nexus URL and credential in each client's configuration. The URL shape per type is on the registry pages; a few examples:

TypeNexusBatleHub
mavenhttps://nexus.example.com/repository/maven-public/https://batlehub.example.com/proxy/<registry>/maven2/
npmhttps://nexus.example.com/repository/npm-group/https://batlehub.example.com/proxy/<registry>/
pypihttps://nexus.example.com/repository/pypi-group/simple/https://batlehub.example.com/proxy/<registry>/simple/
nugethttps://nexus.example.com/repository/nuget-group/index.jsonhttps://batlehub.example.com/proxy/<registry>/nuget/v3/index.json

The credential becomes a BatleHub personal access token. Clients that send username and password (Maven, pip, NuGet) keep doing so, with the token as the password — the username each one expects is on its registry page.

batlehub-cli registry suggest --client-env reads a project's manifests and prints the matching registries and client settings — see the CLI reference.

5. Switch Nexus off ​

Nexus can go once:

  • no BatleHub registry lists a Nexus URL in upstreams;
  • the Nexus request log shows no client other than BatleHub;
  • every hosted repository has been copied, or deliberately left behind.

Keep a read-only Nexus, or a backup of its blob stores, for as long as your retention policy asks.

Released under the Apache 2.0 License. Made with care and too much coffee.