CI/CD Project Part 3: Jenkins + Nexus + SonarQube + Docker
Install the DevOps toolchain — the Jenkins bash install script, Nexus in Docker, SonarQube in Docker, and kubectl on Jenkins.
Series
End-to-End CI/CD Pipeline Project
- 0Real Project: Deploy a Java App with Jenkins, SonarQube, Nexus, Docker & Kubernetes
- 1CI/CD Project Part 1: Provision AWS Infrastructure
- 2CI/CD Project Part 2: Install Kubernetes with kubeadm
- 3CI/CD Project Part 3: Jenkins + Nexus + SonarQube + DockerReading
- 4CI/CD Project Part 4: The Complete Jenkinsfile (11 Stages)
- 5CI/CD Project Part 5: Monitoring with Prometheus + Grafana
Part 3 — Install the DevOps Tools
Install Docker (on Jenkins, Nexus/Sonar, and any node that needs it)
install_docker.sh:
#!/bin/bash
sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" \
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo usermod -aG docker $USER
Run: chmod +x install_docker.sh && ./install_docker.sh — logout / login to pick up the group.
Install Jenkins
install_jenkins.sh:
#!/bin/bash
sudo apt install -y openjdk-17-jre-headless
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \
https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
https://pkg.jenkins.io/debian-stable binary/" \
| sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install -y jenkins
sudo systemctl enable --now jenkins
Open http://<jenkins-ip>:8080 → unlock with:
sudo cat /var/lib/jenkins/secrets/initialAdminPassword
Install suggested plugins in the wizard.
Install kubectl on Jenkins (so it can kubectl apply)
curl -o kubectl https://amazon-eks.s3.us-west-2.amazonaws.com/1.29.0/2024-01-04/bin/linux/amd64/kubectl
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
kubectl version --client
Copy the K8s admin kubeconfig from the master:
scp -i devops.pem ubuntu@<master-ip>:~/.kube/config ~/kubeconfig
Later in Jenkins we'll upload this as a Secret File credential named k8-cred.
Nexus (artifact + Docker registry) — Docker one-liner
docker run -d --name nexus -p 8081:8081 sonatype/nexus3:latest
docker ps
Get initial admin password:
docker exec -it nexus /bin/bash
cat /nexus-data/admin.password
exit
Log into http://<nexus-ip>:8081 → complete setup → note the password.
SonarQube — Docker one-liner
docker run -d --name sonar -p 9000:9000 sonarqube:lts-community
Default login: admin / admin → change it. Open http://<sonar-ip>:9000.
Install Jenkins plugins for the pipeline
Manage Jenkins → Plugins → Available. Install:
- Eclipse Temurin Installer (JDK)
- Pipeline Maven Integration
- Config File Provider
- SonarQube Scanner
- Kubernetes CLI
- Docker
- Docker Pipeline
Restart Jenkins after install.
Configure global tools
Manage Jenkins → Tools:
- JDK 17 (name it
jdk17, install fromadoptium) - Maven 3 (name it
maven3) - SonarQube Scanner (name it
sonar-scanner) - Docker (install automatically)
Credentials to add
Manage Jenkins → Credentials → Global:
| ID | Kind | Purpose |
|---|---|---|
git-cred | Username with password (GitHub PAT) | Clone the repo |
sonar-token | Secret text (token from SonarQube) | Quality gate |
docker-cred | Username with password (Docker Hub) | Push image |
k8-cred | Secret file (kubeconfig from master) | Deploy |
Everything is ready for the Jenkinsfile in Part 4.
Keep reading
You may also like
devops
Git Handbook – Quick Reference
A complete collection of Git commands and notes, covering setup, commits, branching, merging, conflicts, and advanced workflows. This handbook is designed as a simple, step‑by‑step guide for beginners and professionals to quickly learn and apply Git in real projects.
devops
Kubernetes Explained for Absolute Beginners
The clearest possible introduction to Kubernetes — what it is, why it exists, and the seven words you need to know.
devops
GitHub Actions: A Complete CI Pipeline
Lint, test, build, publish — a battle-tested workflow template.
Discussion (0)
No comments yet. Be the first to weigh in.