KalpOps Evolving Eternally
"Recall the face of the poorest and weakest person you have seen, and ask if the step you contemplate is going to be of any use to them." โ€” Mahatma Gandhi

Authenticating...

Access Denied

Your account has been blocked from accessing this site.

If you believe this is an error, please contact the site administrator.

โ† Back to Portfolio
DevOps

Jenkins Pipeline Optimization & Modularization

Refactored a complex, monolithic 500+ line Jenkinsfile into a clean, modular architecture with 3 focused jobs, external tool scripts, and parameterized execution โ€“ enabling faster builds and local pre-commit checks.

JenkinsGroovyBashSonarQubeGradleGit

๐Ÿ”ฅ The Problem: Monolithic Pipeline Complexity

The original Jenkinsfile had grown into a 500+ line monolith with 10+ stages, embedded functions, and tightly coupled logic โ€“ making it slow, hard to maintain, and impossible to test locally.

10+ Pipeline Stages
500+ Lines of Groovy
25+ Min Build Time
0 Local Testability
โฑ๏ธ Long feedback loops โ€“ devs wait 25+ mins for simple checks
๐Ÿ”’ No local validation โ€“ must push to trigger pipeline
๐Ÿงฉ Everything coupled โ€“ can't run checks without full build
๐Ÿ“„ Hard to debug โ€“ embedded functions, no separation

๐Ÿš€ The Solution: Modular 3-Job Architecture

I redesigned the pipeline around separation of concerns, splitting the monolith into three focused jobs with external tooling that developers can run locally.

New Architecture
โœ…
CHECK
Validation & Static Analysis
Runs Locally
โ†’
๐Ÿ”จ
BUILD
Compile & Package
โ†’
๐Ÿงช
TEST
Unit Tests & Quality Gates

๐Ÿ”„ Key Architectural Changes

1 Stage Consolidation
Before: 10+ stages (SQL checks, Binary checks, Password checks, JIRA validation, PR detection, Compile, Tests, Sonar...)
After: 3-4 stages per job (Check, Build, Test, Quality Gate)
2 External Tool Scripts
Before: All logic embedded in Jenkinsfile as @NonCPS functions
After: /tools directory with standalone scripts called from pipeline
3 Local Execution
Before: Must push code to trigger any validation
After: ./tools/check.sh runs all checks locally before commit
4 Parameterized Control
Before: Fixed behavior, no developer override
After: Flags like --skip-sql, --only-java, --fast-mode

๐Ÿ“‚ The /tools Directory Structure

Scripts moved out of the Jenkinsfile into standalone, testable utilities:

๐Ÿ“œ
check-sql.sh Validates SQL files are in correct paths, DDL/DML naming, PL/SQL duplication
๐Ÿ“œ
check-binaries.sh Blocks .war, .jar, .tar, .gz, .zip files from being committed
๐Ÿ“œ
check-secrets.sh Scans property files for encrypted passwords (AES, 3DES)
๐Ÿ“œ
check-jira.sh Validates PR title contains valid JIRA ID format
๐Ÿ“œ
detect-changes.sh Identifies affected modules for selective compilation
๐Ÿš€
check.sh Master script โ€“ runs all checks with optional flags

โš™๏ธ Parameterized Execution Flags

Both the pipeline and local scripts now accept flags for granular control:

--skip-sql Skip SQL validation checks
--skip-binaries Skip binary file detection
--only-java Only compile Java, skip JSP
--only-jsp Only compile JSP files
--skip-tests Skip unit test execution
--skip-sonar Skip SonarQube analysis
--fast-mode Minimal checks for quick iteration
--modules=X,Y Build only specific modules

๐Ÿ† Results Achieved

Before

  • 25+ minute full pipeline
  • No local validation
  • 10+ tightly coupled stages
  • 500+ lines in Jenkinsfile
  • Hard to debug failures
  • No selective execution
โ†’

After

  • ~8 minute optimized builds
  • Local pre-commit checks
  • 3 focused, independent jobs
  • ~100 lines per Jenkinsfile
  • Clear, isolated failures
  • Parameterized control
70% Faster Builds
5x Smaller Jenkinsfiles
100% Local Testability
โˆž Developer Happiness

Session Timeout Warning

You've been inactive. Your session will expire in 60 seconds.