Experiment 6
Experiment 6
1. Overview
What is a CI Pipeline?
A Continuous Integration (CI) Pipeline automates the process of building, testing, and
integrating code changes every time code is committed to the repository. This pipeline:
Automatically checks out the latest code.
Compiles the application.
Runs tests to catch errors early.
Notifies the team of build/test results.
Why Use Jenkins for CI?
Automation: Jenkins automates the build and test cycle, reducing manual intervention.
Immediate Feedback: Developers get rapid notifications of any integration issues.
Extensibility: With hundreds of plugins available, Jenkins can integrate with version
control systems, build tools (Maven, Gradle), testing frameworks, and more.
Pipeline as Code: Using Jenkins Pipelines (defined in a Jenkinsfile), you can
manage the CI process as part of your source code repository.
}
stage('Build')
{ steps {
// Run Maven build
sh 'mvn clean package'
}
}
stage('Test') {
steps {
// Optionally, separate test execution if needed
sh 'mvn test'
}
}
}
post {
always {
// Archive test reports
junit '**/target/surefire-reports/*.xml'
}
success {
echo 'Build and tests succeeded!'
}
failure {
echo 'Build or tests failed.'
}
}
}