0
0
Jenkinsdevops~30 mins

CI/CD pipeline mental model in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
CI/CD Pipeline Mental Model with Jenkins
📖 Scenario: You are working as a DevOps engineer. Your team wants to automate the process of building, testing, and deploying a simple application using Jenkins. This will save time and reduce errors by running these steps automatically whenever code changes.
🎯 Goal: Build a simple Jenkins pipeline script that models the CI/CD process with stages for build, test, and deploy. You will create the pipeline steps one by one and finally print the pipeline structure.
📋 What You'll Learn
Create a Jenkins pipeline script with three stages: Build, Test, Deploy
Define a variable for the application name
Use the variable in the pipeline stages
Print the pipeline stages and application name at the end
💡 Why This Matters
🌍 Real World
Automating software build, test, and deployment saves time and reduces human errors in real projects.
💼 Career
Understanding Jenkins pipelines is essential for DevOps roles to implement continuous integration and continuous delivery.
Progress0 / 4 steps
1
Define the application name variable
Create a variable called appName and set it to the string "MyApp".
Jenkins
Need a hint?

Use def appName = "MyApp" to create the variable.

2
Create the Jenkins pipeline with stages
Add a pipeline block with an agent any and a stages section containing three stages named Build, Test, and Deploy.
Jenkins
Need a hint?

Use pipeline { agent any stages { stage('Build') { steps { ... } } } structure.

3
Use the appName variable inside each stage
Inside each stage's steps, add an echo statement that prints the action and uses the appName variable with ${appName} syntax. For example, in the Build stage, print "Building ${appName}...".
Jenkins
Need a hint?

Use echo "Building ${appName}..." inside the Build stage steps, and similarly for Test and Deploy.

4
Print the pipeline stages and application name
Add a post section with a always block that prints "Pipeline completed for ${appName}" using echo.
Jenkins
Need a hint?

Use post { always { echo "Pipeline completed for ${appName}" } } after the stages block.