Cloud Native 18 min read

Comprehensive Guide to Building a CI/CD Pipeline with Jenkins, Docker, SonarQube, and ArgoCD on AWS and Kubernetes

This step‑by‑step tutorial explains how to configure version control, provision an AWS EC2 instance, install Java and Jenkins, set up Docker and SonarQube, write a Jenkinsfile, and deploy the application automatically with ArgoCD on a Kubernetes cluster.

DevOps
DevOps
DevOps
Comprehensive Guide to Building a CI/CD Pipeline with Jenkins, Docker, SonarQube, and ArgoCD on AWS and Kubernetes

Introduction – Continuous Integration and Continuous Delivery (CI/CD) are essential for modern software development. Jenkins is a popular tool for building CI/CD pipelines. This guide walks through the complete setup of a CI/CD pipeline using Jenkins, Docker, SonarQube, Helm, and ArgoCD.

Tools and Technologies – The pipeline uses GitHub for source control, Maven for builds, SonarQube for code quality, Docker for containerisation, Jenkins for CI, Kubernetes for orchestration, and ArgoCD for continuous deployment.

Configure Version Control – Create a private Git repository on GitHub (or GitLab) and generate a personal access token with repo scope. Clone the repository locally with:

git clone

Create an AWS EC2 Instance – Launch an EC2 instance (e.g., t2.large) via the AWS console, configure security groups to allow ports 22, 8080, and 9000, add a key pair, and note the public IP address.

Access the Instance – Use an SSH client such as MobaXterm to connect to the instance using the private key.

Install Java – On the instance run:

sudo apt update
sudo apt install openjdk-11-jdk
java -version

Install Jenkins – Create an installation script install_jenkins.sh :

#!/bin/bash
# Download Jenkins GPG key
sudo wget -O /usr/share/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key
# Add repository
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 jenkins -y

Make the script executable ( chmod +x install_jenkins.sh ) and run it ( ./install_jenkins.sh ). Adjust the firewall to allow inbound traffic on port 8080 and access Jenkins UI at http:// :8080 .

Install SonarQube (Docker) – Install Docker using install_docker.sh (script omitted for brevity), then pull and run SonarQube:

docker pull sonarqube
docker run -d --name sonarqube -p 9000:9000 sonarqube

SonarQube is reachable at http:// :9000 (default credentials admin/admin).

Integrate SonarQube with Jenkins – Install the SonarQube Scanner plugin, add the SonarQube server URL, and store the generated token as a secret credential in Jenkins.

Write the Jenkinsfile – The pipeline script (Groovy) defines stages for checkout, build, test, SonarQube analysis, Docker image build & push, deployment file update, and Helm deployment. Example snippet:

pipeline {
    agent { docker { image 'abhishekf5/maven-abhishek-docker-agent:v1' args '--user root -v /var/run/docker.sock:/var/run/docker.sock' } }
    stages {
        stage('Checkout') { steps { sh 'echo passed' } }
        stage('Build and Test') { steps { sh 'cd spring-boot-app && mvn clean package' } }
        stage('Static Code Analysis') { environment { SONAR_URL = "http://54.252.140.131:9000" }
            steps { withCredentials([string(credentialsId:'sonarqube', variable:'SONAR_AUTH_TOKEN')]) {
                sh 'cd spring-boot-app && mvn sonar:sonar -Dsonar.login=$SONAR_AUTH_TOKEN -Dsonar.host.url=${SONAR_URL}' } } }
        // Additional stages omitted for brevity
    }
}

Set Up ArgoCD – Install the ArgoCD Operator via OLM, apply a basic ArgoCD custom resource ( argocd-basic.yml ), and expose the UI using a NodePort service. Retrieve the admin password from the Kubernetes secret example-argocd-cluster (base64‑decode it) and log in.

Deploy with ArgoCD – In the ArgoCD UI, create an application pointing to the Git repository containing the Helm charts or Kubernetes manifests. Enable automatic sync so that any changes pushed to the repo are deployed to the cluster.

Conclusion – The guide demonstrates end‑to‑end integration of source control, build, test, code quality, containerisation, and continuous deployment, providing a reproducible CI/CD pipeline that improves delivery speed and software quality.

DockerCI/CDKubernetesAWSSonarQubeJenkinsArgoCD
DevOps
Written by

DevOps

Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.