-
Notifications
You must be signed in to change notification settings - Fork 1
10_Declaritive_Pipeline
bhupender rawat edited this page Jun 20, 2021
·
5 revisions
In this lab we will create a Jenkins Declarative Pipeline for CI :
- Create a Jenkins Pipeline that will kick start the CI process if a commit is made.
- Add a Stage in the pipeline to perform to Code stability.
- Add a Stage in the pipeline to perform code quality analysis.
- Add a Stage in the pipeline to perform code coverage analysis.
- Add a Stage in the pipeline to generate reports for code quality & analysis.
- Add a Stage in the pipeline to send Slack and Email notifications.
- Create a pipeline Jenkins Job with "Declarative Pipeline CI" and add this snippet
pipeline {
agent any
stages {
stage("Clonning the codebase") {
steps {
git 'https://github.com/OT-TRAINING/Jenkins'
}
}
}
}
- Configure the pipeline with this code
pipeline {
agent any
stages {
stage("Clonning the codebase") {
steps {
git 'https://github.com/OT-TRAINING/Jenkins'
}
}
stage("Code Stability") {
steps {
sh "cd SampleJavaWebApp; mvn clean package"
}
}
}
}
- Configure the pipeline with this code
pipeline {
agent any
stages {
stage("Clonning the codebase") {
steps {
git 'https://github.com/OT-TRAINING/Jenkins'
}
}
stage("Code Stability") {
steps {
sh "cd SampleJavaWebApp; mvn -B clean package"
}
}
stage("Code Quality") {
steps {
sh "cd SampleJavaWebApp; mvn -B checkstyle:checkstyle"
recordIssues(tools: [checkStyle()])
}
}
}
}
- Configure the pipeline with this code
pipeline {
agent any
stages {
stage("Clonning the codebase") {
steps {
git 'https://github.com/OT-TRAINING/Jenkins'
}
}
stage("Code Stability") {
steps {
sh "cd SampleJavaWebApp; mvn -B clean package"
}
}
stage("Code Quality") {
steps {
sh "cd SampleJavaWebApp; mvn -B checkstyle:checkstyle"
recordIssues(tools: [checkStyle()])
}
}
stage("Code Coverage") {
steps {
sh "cd SampleJavaWebApp; mvn -B cobertura:cobertura"
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/target/site/cobertura/coverage.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}
}
}
}
pipeline {
agent any
stages {
stage("Clonning the codebase") {
steps {
git 'https://github.com/OT-TRAINING/Jenkins'
}
}
stage("Code Stability") {
steps {
sh "cd SampleJavaWebApp; mvn -B clean package"
}
}
stage("Code Quality") {
steps {
sh "cd SampleJavaWebApp; mvn -B checkstyle:checkstyle"
recordIssues(tools: [checkStyle()])
}
}
stage("Code Coverage") {
steps {
sh "cd SampleJavaWebApp; mvn -B cobertura:cobertura"
cobertura autoUpdateHealth: false, autoUpdateStability: false, coberturaReportFile: '**/target/site/cobertura/coverage.xml', conditionalCoverageTargets: '70, 0, 0', failUnhealthy: false, failUnstable: false, lineCoverageTargets: '80, 0, 0', maxNumberOfBuilds: 0, methodCoverageTargets: '80, 0, 0', onlyStable: false, sourceEncoding: 'ASCII', zoomCoverageChart: false
}
}
stage("Send Notitications") {
steps {
emailext body: '', subject: '', to: '[email protected]'
slackSend message: 'Build is Successful'
}
}
}
}