-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Create a Declarative CI pipeline for java based project that contains various stages like * Code checkout * Run below stages in parallel - Code stability. - Code quality analysis. - Code coverage analysis. * Generate a report for code quality & analysis. * Publish artifacts. * Send Slack and Email notifications. The user should have the option to skip various scans in the build execution. And before publish there should be an approval stage to be set in place to approve or deny the publish and if approved the step should execute and the user should be notified post successful/failed Repeat the same using Scripted Pipeline.
This pipeline automates the process of building, testing, analysing, and deploying a Java-based project. The pipeline contains various stages that run in sequence to ensure code stability, quality, and coverage, generate reports, publish artifacts, and send notifications. The pipeline also provides the option to skip certain scans and requires approval before publishing the artifacts.
- Jenkins server
- Jenkins plugins:
- Pipeline
- Slack Notification
- Email Extension
The pipeline contains the following stages: Code Checkout: This stage checks out the source code from the version control system.
Code Checkout
Parallel Stages:
Parallel Stages
Parallel Stages
Code Stability: This stage compiles the code, runs unit tests, and checks for code stability.
Code Stability
Code Quality Analysis: This stage analyzes the code quality using tools like SonarQube, Checkstyle, and PMD.
Code Quality Analysis
Code Coverage Analysis: This stage checks the code coverage using tools like JaCoCo and Cobertura.
Code Coverage Analysis
Generate Report: This stage generates a report for code quality and analysis using SonarQube.
Publish Artifacts: This stage publishes the artifacts to the artifact repository.
Publish Artifacts
Approval Stage: This stage requires manual approval before publishing the artifacts. If approved, the pipeline moves to the next stage.
Approval Stage
Notification Stage: This stage sends notifications via Slack and email to notify the user of the pipeline status.
Notification Stage
Notification Stage

agent {
label { label 'node2' }
}
options {
skipDefaultCheckout()
}
stages {
stage('Checkout') {
steps {
git 'https://github.com/opstree/spring3hibernate'
}
}
stage('Build') {
steps {
sh ''' mvn clean install '''
}
}
stage('Parallel stages') {
parallel {
stage('Code stability') {
steps {
sh ''' mvn surefire:test '''
}
}
stage('Code_quality_analysis') {
steps {
sh ''' mvn checkstyle:checkstyle '''
}
}
stage('Code_coverage_analysis') {
steps {
sh '''mvn cobertura:cobertura'''
}
}
}
}
stage('Publish_artifact') {
input {
message 'Do you want to publish?'
ok 'Yes, we want to publish'
}
steps {
sh ''' mvn deploy '''
}
}
}
post{
failure{
slackSend( channel: "#mukul-jenkins", token: "LxNrJ7Srr4oEa0Fw7tdLxRPW", color: "good", message: "Job URL: ${JOB_DISPLAY_URL} || BuildNumber: ${BUILD_NUMBER} || Job: ${JOB_NAME} Failed")
}
aborted{
slackSend( channel: "#mukul-jenkins", token: "LxNrJ7Srr4oEa0Fw7tdLxRPW", color: "good", message: "Job URL: ${JOB_DISPLAY_URL} || BuildNumber: ${BUILD_NUMBER} || Job: ${JOB_NAME} Aborted")
}
success{
slackSend( channel: "#mukul-jenkins", token: "LxNrJ7Srr4oEa0Fw7tdLxRPW", color: "good", message: "Job URL: ${JOB_DISPLAY_URL} || BuildNumber: ${BUILD_NUMBER} || Job: ${JOB_NAME} Successfully run")
}
unstable{
slackSend( channel: "#mukul-jenkins", token: "LxNrJ7Srr4oEa0Fw7tdLxRPW", color: "good", message: "Job URL: ${JOB_DISPLAY_URL} || BuildNumber: ${BUILD_NUMBER} || Job: ${JOB_NAME} Unstable")
}
}
}