Back to Projects
cicd factory

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

  • 1

    Groovy Library Structure

    Learn how to lay out standard structure folders (src/ classes, vars/ custom pipeline steps) to modularize workflows.

  • 2

    Automated Dockerization Cycles

    Construct dynamic container tasks that compile, tag, and publish application artifacts directly to registries.

  • 3

    SonarQube Quality Gate Integrations

    Assert static security analysis parameters and check external webhooks before allowing stages to deploy.

  • 4

    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

1 Bind Library in Jenkins System Console

Register the repository as a Global Pipeline Library inside your Jenkins control panel:

Configure System β†’ Global Pipeline Libraries β†’ Add Library:

parameters
Library Name: jenkins-shared-library
Default Version: main
Retrieval Method: Modern SCM (Git)
Project Repository: https://github.com/Pradeeptalari14/jenkins-shared-library.git
2 Import Library inside Project Jenkinsfiles

Reference the imported Groovy helpers at the top of your microservice build files:

groovy
@Library('jenkins-shared-library') _

// This imports the library and makes custom step wrapper methods available
3 Call standardPipeline Wrapper Step

Run standard build wrappers dynamically, passing target configurations:

groovy
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

graph TD
    Commit[Git Code Push] -->|Webhook Trigger| Jenkins[Jenkins CI Controller]
    Jenkins -->|Compile Groovy| Lib[Shared Library Loader]
    
    subgraph Declarative Pipeline Steps
        Lib -->|Invoke| Docker[Docker Build & Push]
        Docker -->|Quality Check| Sonar[SonarQube Scanner]
        Sonar -->|Verify Gate| Approval{Gate Pass?}
        Approval -->|Yes| Helm[Helm EKS Deploy]
        Approval -->|No| Notify[Slack Alert Failure]
    end
    
    Helm -->|Push Helm Charts| Kubernetes[AWS EKS Target]
    Kubernetes -->|Success Callback| Success[Slack Alert OK]
            

πŸ› οΈ 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') }
πŸ“‹ Code copied to clipboard!