Nexus

1. Nexus kya hota hai?
Nexus Repository Manager ek artifact repository tool hai.
Iska kaam hota hai build ke output (artifacts) ko safely store, manage aur share karna.
Artifact examples:
JAR / WAR files
Docker images
npm packages
Maven dependencies
Industry me mostly Sonatype Nexus Repository Manager use hota hai.
2. Nexus kyun use karte hain?
Real problem bina Nexus ke:
Har build ke baad file local Jenkins me padi rehti hai
Jenkins crash hua to artifacts gone
Rollback mushkil
Dependency version ka control nahi
Nexus ye problems solve karta hai.
Use cases:
Central artifact storage
Versioning (v1, v2, v3…)
Rollback support
Faster builds (cached dependencies)
CI/CD pipelines ko stable banana
3. Nexus kaha use hota hai? (CI/CD Flow)
Typical flow:
Code → Jenkins Build → Artifact → Nexus → Deploy
Jenkins artifact banata hai
Nexus me upload karta hai
Deployment wahi se hota hai
Production me Jenkins se direct deploy rarely hota hai.
4. Nexus repository types (Very Important)
1. Hosted Repository
Tum apne artifacts yahan store karte ho
Example: company ke WAR files
2. Proxy Repository
External repos ka cache
Example: Maven Central, npm registry
3. Group Repository
Hosted + Proxy ka combo
Jenkins sirf group repo se connect karta hai
Interview me ye 3 types bolna must hai.
5. Nexus supported formats
Maven (Java)
npm (NodeJS)
Docker
PyPI (Python)
Helm
Raw files
Isliye Nexus almost har tech stack ke sath chalta hai.
6. Nexus Setup (Step by Step)
Step 1: Server requirements
OS: Ubuntu 20.04+ (recommended)
RAM: minimum 4 GB
Java: required (Java 8+)
Step 2: Java install karo
sudo apt updatesudo apt install openjdk-11-jdk -yjava -version
Step 3: Nexus download karo
cd /optsudo wget https://download.sonatype.com/nexus/3/latest-unix.tar.gzsudo tar -xvf latest-unix.tar.gzsudo mv nexus-3* nexussudo mv sonatype-work nexusdata
Step 4: Nexus user create karo
sudo adduser nexussudo chown -R nexus:nexus /opt/nexussudo chown -R nexus:nexus /opt/nexusdata
Step 5: Nexus ko user ke sath run karo
Edit file:
sudo vi /opt/nexus/bin/nexus.rc
Add:
run_as_user="nexus"
Step 6: Nexus start karo
sudo su - nexus/opt/nexus/bin/nexus start
Check status:
/opt/nexus/bin/nexus status
Step 7: Browser me open karo
http://<SERVER-IP>:8081
Default credentials:
Username: admin
Password:
cat /opt/nexusdata/admin.password
7. First-time Nexus configuration
Password change karo
Anonymous access disable karo
Repository create karo
Example:
Maven Hosted
Version policy: Release
Deployment policy: Allow redeploy
8. Jenkins ke sath Nexus integration (Basic idea)
Jenkins pipeline:
Build karo
Artifact generate karo
Nexus me push karo
Maven example:
mvn deploy
Nexus URL + credentials Jenkins me configure hote hain.
9. Best Practices (Real-world)
Jenkins me artifacts store mat karo
Nexus ke liye alag disk use karo
Cleanup policy enable karo
Snapshot aur Release repos alag rakho
Nexus backup regular lo
10. Interview one-liner
Nexus is an artifact repository manager used in CI/CD pipelines to store, version, and manage build artifacts, enabling reliable deployments and easy rollbacks.