Jenkins Pipeline Shared Library
Enterprise reusable Groovy-based library designed to standardize delivery pipelines across microservice stacks. Features automated container builds, SonarQube quality gates, security audits, and declarative Helm-based deployments.
π‘ What We Will Learn in This Repo
-
Groovy Library Structure
Learn how to lay out standard structure folders (
src/classes,vars/custom pipeline steps) to modularize workflows. -
Automated Dockerization Cycles
Construct dynamic container tasks that compile, tag, and publish application artifacts directly to registries.
-
SonarQube Quality Gate Integrations
Assert static security analysis parameters and check external webhooks before allowing stages to deploy.
-
Automated Helm EKS Upgrades
Perform blue-green or rolling container migrations using dry-run verification and automatic rollbacks on failure.
π Step-by-Step Installation Guide
Register the repository as a Global Pipeline Library inside your Jenkins control panel:
Configure System β Global Pipeline Libraries β Add Library:
Library Name: jenkins-shared-library
Default Version: main
Retrieval Method: Modern SCM (Git)
Project Repository: https://github.com/Pradeeptalari14/jenkins-shared-library.git
Reference the imported Groovy helpers at the top of your microservice build files:
@Library('jenkins-shared-library') _
// This imports the library and makes custom step wrapper methods available
Run standard build wrappers dynamically, passing target configurations:
standardPipeline {
appName = 'my-web-service'
dockerRegistry = '123456789012.dkr.ecr.us-east-1.amazonaws.com'
sonarProjectKey = 'my-web-service'
helmReleaseName = 'web-service-release'
}
π Things You Need to Replace (Customization Checklist)
Adapt default pipeline endpoints inside your library to target your server properties:
| Target Element | File Location | Placeholder / Code target |
|---|---|---|
| SonarQube Server Endpoints | vars/standardPipeline.groovy |
withSonarQubeEnv('sonar-server') (replace with your server identifier) |
| AWS Credentials IDs | vars/buildImage.groovy |
aws-ecr-credentials (credentials ID set in Jenkins) |
| Slack Webhook URLs | vars/notifySlack.groovy |
slackSend channel: '#deployments' (adjust channel tags) |
| Chart paths | vars/deployHelm.groovy |
chart: './charts/app' (update path to local charts) |
π Architectural Workflow
π οΈ Useful Jenkinsfile Import Reference
Standard project layout wrapper integration schema:
// Example microservice Jenkinsfile structure:
@Library('jenkins-shared-library') _
node {
stage('Initialize') {
echo "Import complete!"
// Run customized steps
checkout scm
}
// Call library variables
buildImage('my-image', 'latest')
deployHelm('my-release', 'default')
}