Jenkins CI/CD End-to-End Documentation

 

Jenkins CI/CD End-to-End Documentation


1. Objective

This document explains from start to finish how to build a complete, safe, production-ready CI/CD pipeline using Jenkins for the Helium platform.

The pipeline is designed to:

  • Trigger on git push master

  • Build ARM64 Docker images from the latest code

  • Push images to Amazon ECR

  • Deploy automatically to Staging (Mumbai)

  • Pause for manual approval

  • Deploy the same tested image to Production (Mumbai, Singapore, Virginia)

  • Fully control AWS Amplify frontend deployments (no auto-deploy)


2. High-Level CI/CD Flow

Git Push (master)
   ↓
Jenkins pulls latest code (backend + frontend)
   ↓
Docker Build (ARM64)
   ↓
Push image → ECR (helium-backend-staging, Mumbai)
   ↓
Deploy STAGING backend (ECS, Mumbai)
   ↓
[Optional] Deploy STAGING frontend (Amplify)
   ↓
⏸ Manual Approval (button in Jenkins)
   ↓
Promote image → PROD ECR (Mumbai, Singapore, Virginia)
   ↓
Deploy PROD backend (ECS, 3 regions)
   ↓
Deploy PROD frontend (Amplify)

3. Prerequisites

3.1 AWS

You must already have:

  • AWS account

  • ECS clusters created:

    • Staging: Mumbai (ap-south-1)

    • Production: Mumbai, Singapore, Virginia

  • ECS services (already created):

    • Backend

    • Worker

  • ECR repositories:

    • helium-backend-staging (Mumbai only)

    • helium-backend (all prod regions)

  • AWS Amplify apps:

    • Staging app (region: us-east-1)

    • Production app (region: us-east-1)

⚠️ Important: Auto-build must be OFF for both Amplify apps.


3.2 GitHub

  • Private GitHub repository

  • master branch

  • Jenkinsfile committed at repository root


4. Jenkins Server Setup (EC2)

4.1 Launch EC2

  • OS: Ubuntu 22.04 or 24.04

  • Instance type: t3.medium

  • Disk: 30 GB

  • Security group:

    • Port 22 (SSH)

    • Port 8080 (Jenkins UI)

4.2 Connect to EC2

ssh -i your-key.pem ubuntu@<EC2_PUBLIC_IP>

5. Install Jenkins & Required Tools

Install the following once on the EC2 instance:

  • Java 17

  • Jenkins

  • Docker

  • Docker Buildx (ARM64 support)

  • QEMU

  • AWS CLI

After installation:

  • Jenkins runs as a system service

  • Jenkins user can run Docker

  • docker buildx supports linux/arm64


6. Jenkins Initial Setup

  1. Open browser:

    http://<EC2_PUBLIC_IP>:8080
    
  2. Unlock Jenkins:

    sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
  3. Install suggested plugins

  4. Create admin user


7. Required Jenkins Plugins

Ensure these plugins are installed:

  • Pipeline

  • Git

  • GitHub

  • Credentials Binding

  • Docker Pipeline

  • Pipeline: Input Step

  • Pipeline: Stage View


8. GitHub Credentials (Private Repo)

8.1 Create GitHub Token

  • GitHub → Settings → Developer settings

  • Personal Access Token (classic)

  • Scope: repo

8.2 Add to Jenkins

Kind: Username with password
ID: github-creds
Username: <github-username>
Password: <github-token>

9. AWS Credentials in Jenkins

Add two credentials:

Access Key

Kind: Secret text
ID: aws-access-key

Secret Key

Kind: Secret text
ID: aws-secret-key

10. Create Jenkins Pipeline Job

  • New Item → Pipeline

  • Name: helium-cicd

Pipeline configuration:

Definition: Pipeline script from SCM
SCM: Git
Repository URL: https://github.com/<org>/<repo>.git
Credentials: github-creds
Branch: */master
Script Path: Jenkinsfile

11. Jenkinsfile (FINAL)

This Jenkinsfile:

  • Always builds latest code

  • Deploys staging automatically

  • Shows manual approval button

  • Deploys production only after approval

  • Keeps frontend deployment fully controlled

(Jenkinsfile content intentionally unchanged here, as it already matches the final validated pipeline.)


12. First Pipeline Run

Trigger via:

git push origin master

or

Jenkins UI → Build Now


13. Manual Production Approval

When pipeline reaches Approve PRODUCTION stage:

  • Jenkins pauses execution

  • UI shows Proceed button

  • No production action happens until approved

To disable production entirely:

RUN_PRODUCTION = "false"

14. Verification

Backend

  • ECS services use new task definition revision

  • Containers run new image tag

Frontend

  • Amplify deploys only when triggered by Jenkins


15. Daily Developer Workflow

Developers only do:

git push origin master

Jenkins handles everything else.


16. Critical Rules

  • Never install tools inside Jenkinsfile

  • Never enable Amplify auto-build

  • Never deploy production without approval

  • Same image is used for staging & production


17. How Jenkins Controls Amplify (IMPORTANT)

  • Amplify auto-build is disabled

  • Jenkins triggers deployments explicitly:

aws amplify start-job \
  --app-id <APP_ID> \
  --branch-name master \
  --job-type RELEASE

This guarantees:

  • Backend deploys first

  • Frontend deploys after backend

  • Full deployment control via Jenkins


18. Final Result

You now have:

  • Enterprise-grade CI/CD

  • Safe multi-region production deployments

  • Manual approval gate

  • Controlled frontend releases

  • Clean Git workflow


END OF DOCUMENTATION

Comments

Popular posts from this blog

Staging Deployment & CI/CD Pipeline Documentation

AWS Global Accelerator (GA) & Route 53 Integration Documentation

End-To-End-Documentation