cd ../
~/projects/cicd-pipeline

$ cat pipeline_overview.md

CI/CD Pipeline

A robust Jenkins declarative pipeline for SpringBoot applications, featuring automated testing, Docker containerization, and seamless deployment to multiple environments.

Declarative
Pipeline as Code
Automated
Testing & Deployment
~3 minutes
Average build time

$ jenkins pipeline --show-stages

Pipeline Stages

1

Source

~10s

Pull latest code from GitHub repository

GitHubGit
2

Build

~2m

Compile SpringBoot application with Maven

MavenJDK 17
3

Test

~1m

Run unit tests and integration tests

JUnitMockito
4

Package

~1m

Build Docker image and push to registry

DockerDocker Hub

$ cat tech_stack.yml

Technology Stack

Jenkins

v2.401.3

CI/CD Orchestration

SpringBoot

v3.1.0

Application Framework

Maven

v3.9.0

Build Tool

Docker

v24.0.2

Containerization

JUnit

v5.9.0

Testing Framework

$ cat features.txt

Key Features

Declarative pipeline as code (Jenkinsfile)
Automated testing with quality gates
Docker containerization for consistent deployments
Environment-specific configurations

$ cat Jenkinsfile

Pipeline Configuration

pipeline {

    agent any

    environment {
        mavenHome = tool "maven-cli"
        dockerHome = tool "docker-plugin"
        PATH = "$mavenHome/bin:$dockerHome/bin:$PATH"
    }

    stages {

        stage("Checkout") {
            steps {
                sh 'mvn --version'
                sh 'docker version'
                echo "Default path - $env.PATH"
                echo "Build number - $env.BUILD_NUMBER"
                echo "Build ID - $env.BUILD_ID"
                echo "Job name - $env.JOB_NAME"
            }
        }

        stage("Compile") {
            steps {
                mvn clean package
            }
        }

        stage("Test") {
            steps {
                mvn test
            }
        }

        stage("Integration Test") {
            steps {
                echo "This is the integration test stage"
                //skipping since no important component to integrate
            }
        }

        stage("Docker Build") {
            steps {
                script {
                    dockerImage = docker.build("neergasm/azure-devops-build-and-push:undefined")
                }
            }
        }

        stage("Docker Push") {
            steps {
                script {
                    docker.withRegistry('', 'dockerhub') {
                        dockerImage.push()
                        dockerImage.push('latest')
                    }
                }
            }
        }
    }
}