Galle, LK--:--5/6 sites live

CI/CD Automation with Jenkins, Git, Docker & Kubernetes

පිටුව 18: Jenkins CI/CD Pipeline එකෙන් Git, Docker සහ Kubernetes එකට සම්බන්ධ කරමු

Continuous Integration & Continuous Delivery සම්පූර්ණ workflow එක, Jenkinsfile Declarative Pipeline, Automated Webhooks, සහ initialAdminPassword.

19 Sept 20264 min readSelf Guide · Stage 11#CI/CD#Jenkins#SRE Labs

Lab 18 of 20 · CI/CD & Jenkins · 5 hands-on activities · bilingual (English + සිංහල)

පිටුව 18: Jenkins CI/CD Pipeline එකෙන් Git, Docker සහ Kubernetes එකට සම්බන්ධ කරමු

Continuous Integration & Continuous Delivery සම්පූර්ණ workflow එක, Jenkinsfile Declarative Pipeline, Automated Webhooks, සහ initialAdminPassword.

💡 සරල සිංහලෙන්: Jenkins CI/CD Pipeline එක ක්‍රියාත්මක වන හැටි

ස්වයංක්‍රීය කර්මාන්ත ශාලාවක් වගේ:

Developer කෙනෙක් තමන්ගේ පරිගණකයේ Code එකක් ලියලා git push කරපු ගමන්:

    1. Jenkins එකට ආරංචි වෙනවා (GitHub Webhook එකෙන්).
    1. Jenkins එක Code එක අරන් Automatic Test කරනවා (Unit Tests).
    1. Docker Image එකක් හදනවා (App එක Container එකකට pack කරනවා).
    1. Kubernetes Cluster එකට Deploy කරනවා (Rolling update එකකින් පාරිභෝගිකයාට Live පේන විදියට).

මේ සම්පූර්ණ වැඩේට විනාඩියක්වත් යන්නේ නෑ! කිසිම ඉංජිනේරුවෙක් අතින් කරන්න ඕන නෑ.

Architectural Foundation & Systems Diagram

DevOps achieves continuous velocity through the CI/CD Pipeline. Whenever a software engineer commits code to Git, the pipeline automates testing, compiling, building a Docker container, and deploying to Kubernetes.

  • ☕ Jenkins Architecture — Jenkins runs as a Java application on port 8080. It features a Controller (schedules jobs, manages GUI) and distributed Executor Agents (run build containers).

  • 📜 The Declarative Jenkinsfile — Pipeline as Code stored directly in the Git repository:
    pipeline { agent any; stages { stage('Test') { ... } stage('Docker Build') { ... } stage('K8s Deploy') { ... } } }

  • ⚡ Git Webhook Automation — GitHub sends an instant HTTP POST webhook to Jenkins upon git push. The pipeline triggers immediately, verifying code health in under 2 minutes!

Step-by-step practical lab

Step 01: Verify CI/CD Jenkins Daemon Runtime State

සිංහලෙන් — Jenkins CI/CD Automation Server එකේ තත්ත්වය පරීක්ෂා කරමු.

Verify that the Jenkins continuous integration and delivery daemon is healthy, enabled, and listening on port 8080.

ExampleShell
systemctl status jenkins
  • status : Jenkins CI/CD controller එකේ සජීවී තත්ත්වය පෙන්වයි.

Expected output

Output
● jenkins.service - Jenkins Continuous Integration Server
   Loaded: loaded (/usr/lib/systemd/system/jenkins.service; enabled)
   Active: active (running) since Wed 2026-09-16 08:00:00 UTC
 Main PID: 2840 (java)
    Tasks: 48 (limit: 9480)
   Memory: 780.2M

SRE Tip: In modern GitOps pipelines, commits pushed to main trigger automated Jenkins builds, run unit tests, build Docker containers, and deploy to Kubernetes!

Step 02: Retrieve initialAdminPassword Unlock Key

සිංහලෙන් — Jenkins Setup Wizard එක unlock කිරීමට initialAdminPassword එක ලබාගනිමු.

Extract the 32-character hexadecimal key required to unlock the Jenkins administrative web GUI.

ExampleShell
cat /var/lib/jenkins/secrets/initialAdminPassword
  • cat : Jenkins ස්ථාපනයෙන් පසු හදන secret admin unlock token එක පෙන්වයි.

Expected output

Output
4f8b91a20c3d4e5f67890123456789ab

SRE Tip: This password is only needed once. During setup, create a dedicated administrative user and disable the default admin.

Step 03: Test Jenkins Web Listener via Curl

සිංහලෙන් — Jenkins Web Port 8080 එකට Curl කරලා පරීක්ෂා කරමු.

Send an HTTP GET probe to verify Jenkins web UI listener is responsive.

ExampleShell
curl -I http://localhost:8080
  • -I : HTTP Headers පමණක් ලබාගෙන Server එකේ තත්ත්වය (HTTP 200 OK) පරීක්ෂා කරයි.

Expected output

Output
HTTP/1.1 200 OK
X-Jenkins: 2.452.1
Server: Jetty(11.0.20)
Content-Type: text/html;charset=utf-8

SRE Tip: In AWS, you must add an Inbound Rule to your EC2 Security Group for Custom TCP Port 8080 from 0.0.0.0/0 to access Jenkins in your browser!

Hands-on practice activities

Work through these yourself — tick them off as you go.

  • Activity 86: Verify Jenkins Daemon Runtime State (Drill) — Confirm that systemd unit jenkins.service is active and running on the host.
  • Activity 87: Retrieve initialAdminPassword Unlock Key (Drill) — Extract the 32-character hexadecimal key to unlock Jenkins Setup Wizard.
  • Activity 88: Test Jenkins Web Listener via Curl (Drill) — Send an HTTP GET probe to verify Jenkins web UI listener is responsive.
  • Activity 89: Declarative Jenkinsfile Syntax Audit (Checkpoint) — Review syntax: pipeline { agent any; stages { stage('Build') { steps { sh 'make' } } } }.
  • Activity 90: Jenkins Default Port Quiz (Quiz) — What is the default TCP port number used by Jenkins for its web user interface? Answer: Port 8080.

Keep going: ← Lab 17 · Lab 19 → · Track your progress in the Self Guide

ExerciseKnowledge check

What is the default TCP port number used by Jenkins for its web user interface? / Jenkins web UI සඳහා භාවිතා වන default TCP port අංකය කුමක්ද?

Finished this one?

Part of Self Guide · Stage 11: SRE Labs II — cloud, containers and delivery. Progress is saved in this browser.

Guide