Back to devops
devops#jenkins#sonarqube#nexus#docker#devops

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.

TechNotesHub Team August 2, 2026 1 views
Log in to download the attached PDF

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:

  1. Eclipse Temurin Installer (JDK)
  2. Pipeline Maven Integration
  3. Config File Provider
  4. SonarQube Scanner
  5. Kubernetes CLI
  6. Docker
  7. Docker Pipeline

Restart Jenkins after install.

Configure global tools

Manage Jenkins → Tools:

  • JDK 17 (name it jdk17, install from adoptium)
  • Maven 3 (name it maven3)
  • SonarQube Scanner (name it sonar-scanner)
  • Docker (install automatically)

Credentials to add

Manage Jenkins → Credentials → Global:

IDKindPurpose
git-credUsername with password (GitHub PAT)Clone the repo
sonar-tokenSecret text (token from SonarQube)Quality gate
docker-credUsername with password (Docker Hub)Push image
k8-credSecret file (kubeconfig from master)Deploy

Everything is ready for the Jenkinsfile in Part 4.

Keep reading

You may also like

Discussion (0)

No comments yet. Be the first to weigh in.

Leave a comment

Comments are reviewed before appearing.