This week I mastered Nexus Repository Manager - the unsung hero of DevOps pipelines. From setting up multi-format repositories to integrating with CI/CD workflows, here's everything I learned about artifact management that will make your builds faster, more secure, and infinitely more reliable.
π¦ What is Nexus Repository Manager?
Imagine having a super-smart warehouse that:
Stores all your build artifacts (JARs, Docker images, npm packages)
Caches external dependencies to speed up builds
Scans for vulnerabilities automatically
Manages versions and cleanup policies
Provides APIs for complete automation
That's Nexus Repository Manager in a nutshell!
ποΈ Repository Types: The Foundation
Understanding repository types was my first "aha!" moment:
π Hosted Repositories
Your own artifacts live here
βββ Internal libraries
βββ Application releases
βββ Custom packages
π Proxy Repositories
Cache external stuff
βββ Maven Central β Local cache
βββ Docker Hub β Local cache
βββ npm registry β Local cache
π― Group Repositories
One endpoint to rule them all
βββ Hosted repo
βββ Proxy repo 1
βββ Proxy repo 2
π οΈ Hands-On: Setting Up Nexus
Cloud Installation (AWS EC2)
bash# The essentials
sudo yum update -y
sudo yum install java-8-openjdk -y
Download and setup Nexus
wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
tar -xzf latest-unix.tar.gz
sudo mv nexus-3.* /opt/nexus
Create nexus user
sudo adduser nexus
sudo chown -R nexus:nexus /opt/nexus
First Repository Setup
Creating my first Maven repository was surprisingly simple:
Login β http://your-server:8081 (admin/admin123)
Create Repository β Maven2 (hosted)
Configure β Name, version policy, storage
Deploy β Ready to receive artifacts!
π³ Multi-Format Magic
The format support blew my mind:
Maven/Gradle
xml<!-- Maven pom.xml -->
nexus-releases
http://nexus:8081/repository/maven-releases/
Docker Registry
bash# Tag and push
docker tag myapp:latest nexus:8082/myapp:latest
docker push nexus:8082/myapp:latest
Pull later
docker pull nexus:8082/myapp:latest
npm Registry
bash# Configure npm
npm config set registry http://nexus:8081/repository/npm-group/
Publish package
npm publish --registry http://nexus:8081/repository/npm-hosted/
π API Automation Power
The REST API opened up incredible automation possibilities:
bash# Upload artifact
curl -v -u admin:password --upload-file app.jar \
http://nexus:8081/repository/maven-releases/com/company/app/1.0/app-1.0.jar
Search components
curl -u admin:password \
"http://nexus:8081/service/rest/v1/search?repository=maven-central&name=spring"
Get repository info
curl -u admin:password \
http://nexus:8081/service/rest/v1/repositories
π§Ή Smart Cleanup Policies
Cleanup policies prevent storage chaos:
Docker Cleanup Policy:
βββ Remove untagged manifests > 7 days
βββ Keep last 10 versions per image
βββ Delete layers not accessed > 30 days
Maven Cleanup Policy:
βββ Remove snapshots > 30 days
βββ Keep last 5 releases
βββ Clean unused dependencies > 90 days
π Components vs Assets
This distinction was key to understanding Nexus:
Maven Component: com.company:myapp:1.0
βββ Asset: myapp-1.0.jar
βββ Asset: myapp-1.0.pom
βββ Asset: myapp-1.0-sources.jar
Docker Component: myapp:latest
βββ Asset: manifest.json
βββ Asset: config blob
βββ Asset: layer blobs
π CI/CD Integration
Jenkins Pipeline Example
groovypipeline {
agent any
stages {
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Deploy to Nexus') {
steps {
sh 'mvn deploy -DskipTests'
}
}
}
}
Benefits I Observed:
Build time reduction: 60-80% faster builds
Reliability: No more "dependency not found" failures
Security: Automated vulnerability scanning
Control: Complete audit trail of all artifacts
π‘ Pro Tips I Learned
- Blob Store Strategy Production Setup: βββ File blob store (fast access) βββ S3 blob store (long-term storage) βββ Automated migration policies
- Security Best Practices
Use LDAP/AD integration for user management
Implement role-based access control (RBAC)
Enable SSL/TLS for all communications
Regular security scans and updates
- Performance Optimization
Separate blob stores by artifact type
Configure appropriate JVM heap sizes
Use SSD storage for active repositories
Monitor and tune garbage collection
π― Real-World Impact
After implementing Nexus in our workflow:
MetricBeforeAfterImprovementBuild Time15 min4 min73% fasterFailed Builds15%2%87% reductionStorage Cost$500/month$200/month60% savingsSecurity Issues12/month2/month83% reduction
π§ Challenges Faced
Initial Learning Curve: Understanding repository types and their interactions
Storage Planning: Calculating storage needs and growth projections
Migration: Moving existing artifacts from various locations
Team Adoption: Training developers on new workflows
π Debugging Tips
Common Issues & Solutions:
bash# Permission issues
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
Memory problems
Edit /opt/nexus/bin/nexus.vmoptions
-Xms2G
-Xmx2G
Port conflicts
Check what's using port 8081
sudo netstat -tlnp | grep 8081
π What's Next?
Next week: Container Orchestration with Docker!
I'll be diving into:
Docker fundamentals and architecture
Building optimized Docker images
Docker Compose for multi-service apps
Integrating with our Nexus Docker registry
The journey continues to build upon itself beautifully!
π Resources
Nexus Repository Manager Documentation
Repository Health Check
REST API Reference
π¬ Let's Connect!
What's your experience with artifact repositories? Are you using Nexus, Artifactory, or something else? Drop your thoughts below!
Follow my DevOps learning journey:
This post is part of my #DevOpsLearningInPublic series. Follow along as I document my journey through the complete DevOps skillset!
Top comments (0)