Professional Documents
Culture Documents
Ex04 - To Create A CI Pipeline Using Jenkins
Ex04 - To Create A CI Pipeline Using Jenkins
Objective:
The objective of this lab is to guide the process of setting up a Continuous Integration (CI)
pipeline using Jenkins to automate the build and testing process of a sample application.
Prerequisites:
• Jenkins installed and accessible (Refer to the "Installing Jenkins on Azure Cloud"
lab manual)
• Sample application source code hosted in a version control system (e.g.,
GitHub)
• Basic understanding of Jenkins and version control systems
Lab Steps:
4. Configure Pipeline:
In the pipeline configuration page:
• Under General, define your pipeline description.
• Under Pipeline, select **Pipeline script from SCM** as the Definition.
• Choose your version control system (e.g., Git) and provide the repository
URL.
▪ Specify the branch to build (e.g., `main` or `master`).
▪ Save your configuration.
5. Create Jenkinsfile:
• In your source code repository, create a `Jenkinsfile` at the root level.
• Define your pipeline stages and steps in the `Jenkinsfile`. For example:
pipeline {
agent any
stages {
stage('Checkout') {
steps {
git branch: 'main', url: 'https://github.com/your-username/sample-
app.git'
}
}
stage('Build') {
steps {
sh 'mvn clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
}
// Add more stages as needed (e.g., Deploy, Publish Artifacts)
}
post {
always {
// Clean up or notify
}
success {
// Notify success
}
failure {
// Notify failure
}
}
}
Result:
In this lab, successfully created a Continuous Integration (CI) pipeline using Jenkins to
automate the build and testing process of a sample application. By integrating Jenkins
with version control systems, we established a robust CI workflow that enhances the
quality and reliability of your software projects.