0
0
Jenkinsdevops~15 mins

Build status badges in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Build status badges
📖 Scenario: You are managing a Jenkins project and want to show the build status on your project page using badges. These badges help your team quickly see if the latest build passed or failed.
🎯 Goal: Create a Jenkins pipeline script that sets up a build status badge URL, configures a badge style, and prints the final badge URL to display the build status.
📋 What You'll Learn
Create a variable called jobName with the exact value MyProject.
Create a variable called badgeStyle with the exact value flat.
Create a variable called badgeUrl that constructs the Jenkins badge URL using jobName and badgeStyle.
Print the badgeUrl to display the badge link.
💡 Why This Matters
🌍 Real World
Build status badges are used in project documentation and dashboards to quickly show if the latest build passed or failed.
💼 Career
Knowing how to create and display build status badges helps DevOps engineers communicate build health clearly to their teams.
Progress0 / 4 steps
1
Set the Jenkins job name
Create a variable called jobName and set it to the string "MyProject".
Jenkins
Need a hint?

Use def jobName = "MyProject" to create the variable.

2
Set the badge style
Create a variable called badgeStyle and set it to the string "flat".
Jenkins
Need a hint?

Use def badgeStyle = "flat" to create the variable.

3
Construct the badge URL
Create a variable called badgeUrl that uses jobName and badgeStyle to build the Jenkins badge URL string exactly as: "https://jenkins.example.com/job/MyProject/badge/icon?style=flat".
Jenkins
Need a hint?

Use Groovy string interpolation with "https://jenkins.example.com/job/${jobName}/badge/icon?style=${badgeStyle}".

4
Print the badge URL
Write a println statement to print the badgeUrl variable.
Jenkins
Need a hint?

Use println(badgeUrl) to display the badge URL.