Skip to content

Artifacts

Manage build artifacts with Nexus Repository Manager.

Overview

Nexus provides artifact storage for Maven artifacts and Docker images. It supports versioning, access control, and repository management.

Access Nexus

Nexus is accessible at: - Local: http://localhost:8081 (via port-forward)

Get admin password

kubectl exec -n playpen-platform deployment/nexus -- \
  cat /nexus-data/admin.password

Repository types

Maven repositories

  • maven-releases: Production releases
  • maven-snapshots: Development snapshots

Docker registry

  • Registry: nexus:5000 (internal) or localhost:5000 (via port-forward)

Publish Maven artifacts

Using Maven

mvn deploy:deploy-file \
  -DgroupId=com.playpen \
  -DartifactId=my-app \
  -Dversion=1.0.0 \
  -Dfile=target/my-app.jar \
  -DrepositoryId=nexus \
  -Durl=http://nexus:8081/repository/maven-releases

Using curl

curl -v \
  -u username:password \
  --upload-file my-app-1.0.0.jar \
  http://nexus:8081/repository/maven-releases/com/playpen/my-app/1.0.0/my-app-1.0.0.jar

Push Docker images

Configure Docker registry

# Login to Nexus registry
docker login nexus:5000 -u username -p password

# Or via port-forward
docker login localhost:5000 -u username -p password

Push image

# Tag image
docker tag my-app:latest nexus:5000/my-app:1.0.0

# Push image
docker push nexus:5000/my-app:1.0.0

Pull image

# Pull from Nexus
docker pull nexus:5000/my-app:1.0.0

Use in Kubernetes

Image pull secrets

Create secret for private registry:

kubectl create secret docker-registry nexus-registry-secret \
  --docker-server=nexus:5000 \
  --docker-username=username \
  --docker-password=password \
  -n playpen-apps

Use in deployment

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  template:
    spec:
      imagePullSecrets:
      - name: nexus-registry-secret
      containers:
      - name: app
        image: nexus:5000/my-app:1.0.0

Create repositories

Via Nexus UI

  1. Log in to Nexus
  2. Go to Settings → Repositories
  3. Create repository → Maven (hosted)
  4. Configure repository settings

Via API

curl -X POST \
  -u admin:password \
  -H "Content-Type: application/json" \
  -d '{
    "name": "maven-custom",
    "recipe": "maven2-hosted",
    "online": true
  }' \
  http://nexus:8081/service/rest/v1/repositories/maven/hosted

Service accounts and API tokens

Create service account

  1. Log in to Nexus
  2. Go to Settings → Users → Create user
  3. Set role: nx-repository-view-*-*-*
  4. Create user

Generate API token

  1. Go to user profile
  2. Generate API token
  3. Use token for authentication:
curl -u username:token \
  http://nexus:8081/service/rest/v1/repositories

Best practices

Versioning

  • Use semantic versioning for releases
  • Use snapshot versions for development
  • Tag Docker images with version numbers

Access control

  • Create service accounts for CI/CD
  • Use API tokens instead of passwords
  • Limit repository access by role

Cleanup

  • Configure retention policies
  • Remove old snapshots regularly
  • Archive releases to external storage

Troubleshooting

Cannot push to registry

  • Verify Docker login
  • Check repository permissions
  • Verify port-forward is active

Maven deploy fails

  • Check repository URL
  • Verify credentials
  • Check network connectivity

Next steps