Understanding Nexus Repository Architecture

Hosted vs Proxy Repositories

Hosted repositories are used to store internally published artifacts, while proxy repositories cache external dependencies (e.g., Maven Central, npmjs). Improper layering of group repositories can lead to lookup inefficiencies or version mismatches.

Blob Store and Database

Nexus stores artifacts in a blob store while maintaining metadata and indexing in an embedded OrientDB database. Misalignment between blob and database can result in artifact lookup failures or 404 errors during builds.

Common Symptoms

  • 404 errors when fetching known artifacts
  • Stale metadata or incorrect versions resolved in CI pipelines
  • Slow artifact uploads or downloads
  • Frequent blob store corruption messages in logs
  • Docker or npm authentication failures despite valid credentials

Root Causes

1. Stale or Corrupt Metadata

Metadata cached from proxy repositories can become stale or desynchronized, especially when upstream sources change versions or delete artifacts. This leads to failed resolution or outdated dependencies being fetched.

2. Blob Store Orphaning

Improper shutdowns, network issues, or bugs can leave blobs in the store without corresponding database records, causing storage bloat and inconsistency.

3. Overlapping Cleanup and CI Requests

Over-aggressive cleanup policies may remove artifacts still referenced by running builds or snapshot dependencies, resulting in build breaks mid-execution.

4. Misconfigured Proxy or Group Ordering

Incorrect ordering of group members (e.g., proxy before hosted) causes Nexus to resolve outdated or external versions even when internal builds exist.

5. Auth Token Caching Issues

Nexus caches authentication tokens and user sessions. Misconfigurations or expired tokens cause 401/403 errors during Docker, npm, or NuGet operations.

Diagnostics and Monitoring

1. Enable DEBUG Logging

In logback.xml, set log level to DEBUG for org.sonatype.nexus.repository and org.sonatype.nexus.blobstore to capture artifact resolution, caching, and blob errors.

2. Use REST API for Blob Integrity Checks

Call /service/rest/v1/blobstores and /service/rest/v1/components to inspect discrepancies between blobs and indexed components.

3. Analyze Task Scheduler for Conflicts

Review concurrent tasks (e.g., cleanup, rebuild index, and expiration) for overlapping schedules that may conflict with active deployments or uploads.

4. Monitor Storage with External Tools

Integrate with Prometheus, Grafana, or Splunk to visualize disk space, blob size, HTTP 404s, and CPU/memory pressure during high throughput events.

5. Review User Token Expiry and Realm Settings

Inspect security-configuration.xml and user settings to ensure correct realm order and that token lifetimes match automation workflows.

Step-by-Step Fix Strategy

1. Rebuild Metadata and Indexes

Admin UI → Repositories → Select → Rebuild Index / Recalculate Metadata

Useful for Maven and NuGet repositories where stale metadata blocks resolution.

2. Run Orphan Blob Cleanup Task

Navigate to Admin → Tasks and run the Admin - Remove Orphaned Blobs task to sync the blob store and database.

3. Adjust Cleanup Policies

Ensure cleanup rules exclude recent snapshots or releases. Use time-based retention and validate with dry-run before enabling auto-delete.

4. Correct Group Ordering

Ensure that hosted repositories precede proxy repositories in group repository configurations to prioritize local artifacts.

5. Clear and Reauthenticate User Tokens

Force token renewal using the REST API or user UI, especially after SSO or LDAP credential updates.

Best Practices

  • Use blob stores on fast SSD-backed volumes with routine backups
  • Apply consistent naming for hosted/proxy/group repos to avoid confusion
  • Enable scheduled index rebuilds post-cleanup tasks
  • Keep authentication realms (e.g., LDAP, Docker Bearer Token) in the correct order
  • Mirror upstreams with caching TTLs to reduce bandwidth and stale content risk

Conclusion

Nexus Repository is essential to modern artifact delivery, but its efficiency depends on correct repository layering, metadata hygiene, and blob-store consistency. Problems such as corrupted indexes, misordered repositories, and outdated credentials can severely impact CI/CD reliability. By applying metadata rebuilds, adjusting cleanup policies, and continuously monitoring repository health, DevOps teams can maintain a secure, performant, and stable artifact management environment.

FAQs

1. Why do builds fail with 404s for artifacts that exist?

Likely due to stale metadata or a corrupted index. Rebuilding the repository index often resolves this.

2. How do I fix orphaned blobs in Nexus?

Run the "Remove Orphaned Blobs" task from the Admin UI to reconcile blob store and metadata database entries.

3. What’s the recommended order for group repositories?

Always list hosted repositories before proxy ones to prioritize internal artifacts during resolution.

4. Can aggressive cleanup break builds?

Yes. Cleanup policies may delete snapshots or releases still used in CI if retention rules are too strict or not validated.

5. How do I resolve Docker login issues?

Ensure that Docker Bearer Token realm is enabled and user tokens have not expired. Re-authenticate if necessary.