Enterprise CI/CD Pipeline on Azure
Automated 8-stage continuous integration and deployment pipeline hosted on Azure VM using Jenkins, Docker, and GitHub Webhooks.
Verified results and performance
Project details
- Role
- DevOps and Cloud Engineer (Solo Project)
- Timeline
- 2024
- Tracks
- devops, software
Technologies and skills
Executive Summary
Modern DevOps engineering relies on rapid, reliable, and secure software delivery pipelines. This project demonstrates an end-to-end continuous integration and continuous deployment (CI/CD) ecosystem built from scratch on Microsoft Azure.
Whenever a developer pushes code or opens a pull request to GitHub, a secure webhook automatically triggers a multi-stage Jenkins pipeline. The pipeline validates code quality with static analysis (ESLint), executes automated unit tests with JUnit reporting, builds a container image, pushes versioned tags to Docker Hub, and performs a live container deployment on the host machine with a verified health check.
System Architecture and Workflow
Technology Stack Breakdown
- Cloud Provider: Microsoft Azure (Hosting compute, virtual networks, and firewall security)
- Operating System: Ubuntu Server 22.04 LTS (Hardened base OS for container runtime and CI controller)
- CI/CD Automation: Jenkins 2.580.1 LTS (Pipeline orchestrator configured via JCasC Configuration as Code)
- Source Control: GitHub and Git (Version control, branch policies, and automated webhook triggers)
- Container Engine: Docker Engine 24.x (Building lightweight, immutable production images)
- Artifact Registry: Docker Hub (Central registry storing release tags)
- App Runtime and Tests: Node.js 20 LTS, Express, Jest (Application runtime, ESLint linter, and JUnit XML test reports)
[ Developer Push ] ────> [ GitHub Webhook ] ────> [ Jenkins Controller (Azure VM) ]
│
┌─────────────────────────────────────────────────────────┴───────────────────────────────────────────────────────┐
│ 8-Stage Declarative Pipeline: │
│ 1. SCM Checkout → 2. Dependencies → 3. ESLint → 4. Jest Tests → 5. Docker Build (:build# & :latest) │
│ 6. Docker Hub Push (Encrypted Auth) → 7. Host Container Deploy → 8. /health Check Loop → Clean Workspace │
└─────────────────────────────────────────────────────────┬───────────────────────────────────────────────────────┘
│
┌─────────────────┴─────────────────┐
▼ ▼
[ Docker Hub Registry ] [ Live Container (:8081) ]
(Versioned & Latest Tags) (/health status: "UP")
Part 1: Provisioning Cloud Infrastructure and Azure Security
The foundation of the infrastructure is hosted on Microsoft Azure with an Ubuntu 22.04 LTS Virtual Machine (vm-jenkins).
1. Network Security Group (NSG) Hardening
To adhere to the Principle of Least Privilege, default open access rules are restricted. Instead of exposing all ports to 0.0.0.0/0, ingress traffic is filtered strictly:
- Port 22 (SSH): Whitelisted to administrator IP addresses for secure remote terminal access.
- Port 8080 (Jenkins Dashboard): Accessible for administration and configured to receive GitHub webhook POST payloads.
- Port 8081 (Application Runtime): Hosts the production Node.js container application.
Microsoft Azure Portal Virtual Machine overview showing vm-jenkins running Ubuntu Server 22.04 LTS, public IP address, and resource health status.
Azure Network Security Group (NSG) configuration explicitly defining inbound rules for Port 22 (SSH), Port 8080 (Jenkins controller), and Port 8081 (live application).
Part 2: Headless Jenkins Installation and Configuration as Code (JCasC)
Manual GUI configurations in Jenkins can cause configuration drift and are difficult to reproduce. In this setup, Jenkins was deployed using Configuration as Code (JCasC).
1. Automated Dependency and Jenkins Installation
The host was prepared with Java 21 LTS, Docker, and official Jenkins LTS repositories:
2. Headless Plugin Management
Using the standalone jenkins-plugin-manager-tool, essential plugins were installed non-interactively without wizard interventions: workflow-aggregator, docker-workflow, blueocean, pipeline-stage-view, github-branch-source, and configuration-as-code.
3. JCasC Specification (jenkins.yaml)
jenkins:
systemMessage: "Enterprise CI/CD Showcase on Azure Ubuntu 22.04"
numExecutors: 2
mode: NORMAL
securityRealm:
local:
allowsSignup: false
authorizationStrategy:
loggedInUsersCanDoAnything:
allowAnonymousRead: false
unclassified:
location:
url: "http://<VM_PUBLIC_IP>:8080/"
# Add official Jenkins keyring and source
sudo mkdir -p /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/jenkins-keyring.asc https://pkg.jenkins.io/debian-stable/jenkins.io-2026.key
echo "deb [signed-by=/etc/apt/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian-stable binary/" | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
# Install Jenkins LTS and Docker
sudo apt-get update -y && sudo apt-get install -y jenkins docker.io openjdk-21-jdk nodejs
# Allow the Jenkins service to communicate with the Docker daemon socket
sudo usermod -aG docker jenkins
sudo systemctl restart docker
Jenkins dashboard displaying the initialized controller and the Multibranch Pipeline job jenkins-app-pipeline monitoring active branches.
Part 3: Declarative Multi-Stage CI/CD Pipeline
The core automation engine is defined inside the repository as a version-controlled Jenkinsfile.
pipeline {
agent any
options {
timestamps()
buildDiscarder(logRotator(numToKeepStr: '10'))
}
environment {
APP_NAME = 'jenkins-demo-app'
PORT = '8081'
}
stages {
stage('Checkout') {
steps {
echo "--> Stage 1: Checking out source code..."
checkout scm
}
}
stage('Install Dependencies') {
steps {
echo "--> Stage 2: Installing Node.js packages..."
sh 'npm install'
}
}
stage('Lint') {
steps {
echo "--> Stage 3: Running ESLint static analysis..."
sh 'npm run lint'
}
}
stage('Unit Tests') {
steps {
echo "--> Stage 4: Executing Jest tests with JUnit XML reporter..."
sh 'npm test'
}
post {
always {
junit testResults: 'test-results/**/*.xml', allowEmptyResults: true
}
}
}
stage('Build Docker Image') {
steps {
echo "--> Stage 5: Building container images..."
sh """
docker build -t ${APP_NAME}:${BUILD_NUMBER} -t ${APP_NAME}:latest .
"""
}
}
stage('Push to Docker Hub') {
steps {
echo "--> Stage 6: Securely pushing images to Docker Hub..."
script {
withCredentials([usernamePassword(credentialsId: 'dockerhub-creds',
usernameVariable: 'DOCKER_USER',
passwordVariable: 'DOCKER_PASS')]) {
sh """
set +x
echo "\$DOCKER_PASS" | docker login -u "\$DOCKER_USER" --password-stdin
docker tag ${APP_NAME}:${BUILD_NUMBER} \$DOCKER_USER/${APP_NAME}:${BUILD_NUMBER}
docker tag ${APP_NAME}:latest \$DOCKER_USER/${APP_NAME}:latest
docker push \$DOCKER_USER/${APP_NAME}:${BUILD_NUMBER}
docker push \$DOCKER_USER/${APP_NAME}:latest
"""
}
}
}
}
stage('Deploy') {
steps {
echo "--> Stage 7: Deploying container on host VM at port ${PORT}..."
sh """
docker stop ${APP_NAME} || true
docker rm ${APP_NAME} || true
docker run -d --name ${APP_NAME} --restart unless-stopped \
-p ${PORT}:8081 -e BUILD_NUMBER=${BUILD_NUMBER} ${APP_NAME}:${BUILD_NUMBER}
# Automated Health Check verification loop
for i in \$(seq 1 15); do
if curl -fs http://localhost:${PORT}/health | grep -q '"status":"UP"'; then
echo "Application verified healthy!"
exit 0
fi
sleep 2
done
exit 1
"""
}
}
}
post {
always {
cleanWs()
}
success {
echo "Pipeline SUCCESS: Build #${BUILD_NUMBER} deployed successfully!"
}
failure {
echo "Pipeline FAILED: Build #${BUILD_NUMBER} halted. Inspect stage logs."
}
}
}
Part 4: Automated GitHub Webhook Integration
Instead of polling GitHub for changes every few minutes (which wastes compute cycles and causes build delays), the pipeline utilizes an event-driven GitHub Webhook.
- Payload URL:
http://<VM_PUBLIC_IP>:8080/github-webhook/ - Trigger Event: Just the push event
- Content Type: application/json
Whenever code is pushed to the repository, GitHub sends an HTTP POST payload to Jenkins, initiating the build in under a second.
GitHub Webhook Recent Deliveries panel displaying an active webhook and green checkmark (200 OK) confirming instant event communication between GitHub and Jenkins.
Part 5: Quality Gates in Action: Fail-Fast vs. Self-Healing
A key mark of production CI/CD is verifying that bad code cannot reach production.
To validate this behavior:
- The Failure Test (
feature/broken-tests): A deliberate breaking assertion was introduced into the unit tests. When pushed, the pipeline halted at Stage 4 (Unit Tests). Because of the failure, Docker build, Docker push, and host deployment were blocked, leaving production intact. - The Recovery (Fix): The test defect was corrected, committed, and pushed. The pipeline immediately turned green across all 8 stages and deployed the update.
Jenkins Pipeline Stage View showing every stage passing: Checkout, Install Dependencies, Lint, Unit Tests, Build Docker Image, Push to Docker Hub, Deploy, and Post cleanup.
Part 6: Secure Registry Distribution on Docker Hub
Hardcoded credentials in scripts or repositories present severe security liabilities.
In this architecture:
- Docker credentials are encrypted inside the Jenkins Credentials Store under the ID
dockerhub-creds. - The pipeline executes using Jenkins
withCredentialswrapper, dynamically binding username and password variables into memory. - Bash debug tracing (
set +x) is enforced during authentication to prevent secret leakage in console outputs. - Each successful build pushes two tags:
- Immutable Build Tag:
${DOCKER_USER}/jenkins-demo-app:${BUILD_NUMBER}(guarantees rollback reproducibility) - Latest Tag:
${DOCKER_USER}/jenkins-demo-app:latest(tracks latest stable release)
- Immutable Build Tag:
Docker Hub public repository showcasing pushed tags with specific build numbers and latest release images.
Part 7: Live Application Verification and Health Checking
Once the image is built and pushed, Jenkins performs a container replacement on the host:
- Stops and removes any outdated container instances.
- Spawns the newly built container bound to port 8081.
- Initiates an automated polling loop against the application /health endpoint:
{
"status": "UP",
"timestamp": "2026-10-21T02:20:00.000Z",
"version": "1.0.1",
"uptime": 12.4
}
- If the application does not return an HTTP 200 with
"status":"UP"within 30 seconds, the deployment marks itself failed, dumps container logs, and alerts the operator.
Key Engineering Takeaways and Lessons Learned
- Configuration as Code Eliminates Snowflake Servers: By codifying Jenkins plugins and credentials through JCasC (
jenkins.yaml), the controller can be recreated in minutes on any virtual machine. - Strict Quality Gates Save Production: Enforcing ESLint and unit testing ahead of containerization ensures that broken dependencies and syntax bugs never consume registry storage or impact production uptime.
- Credential Masking is Mandatory: Using
withCredentialsblocks and keeping tokens strictly in memory avoids accidental token exposure in build logs. - Health Check Probing Prevents Silent Failures: A container might exit seconds after starting due to missing environment variables. Running an active HTTP curl health check within the deployment stage provides guaranteed verification.
Future Enhancements
- Kubernetes (AKS) Migration: Transitioning single-VM Docker deployment to a scalable Azure Kubernetes Service (AKS) cluster using Helm charts.
- Vulnerability Scanning: Integrating security linters such as Trivy into the pipeline to inspect base images for CVE vulnerabilities before pushing.
- ChatOps Alerts: Integrating automated webhook notifications to a dedicated channel for instant build status alerts.
Discuss this project
Have questions about the architecture or design decisions?