0
0
Jenkinsdevops~30 mins

Test result trends in Jenkins - Mini Project: Build & Apply

Choose your learning style9 modes available
Test Result Trends in Jenkins
📖 Scenario: You are a Jenkins administrator who wants to track how test results change over time for a software project. This helps the team see if tests are improving or failing more often.
🎯 Goal: Build a simple Jenkins pipeline script that collects test results from multiple builds and prints a trend summary showing how many tests passed and failed in each build.
📋 What You'll Learn
Create a list variable called builds with test result data for 3 builds
Add a variable called threshold to mark the minimum passing tests
Use a for loop to analyze each build's test results and create a summary list
Print the summary list showing test pass/fail trends
💡 Why This Matters
🌍 Real World
Tracking test result trends helps teams quickly spot if recent changes break tests or improve quality.
💼 Career
Jenkins administrators and DevOps engineers often create scripts to analyze build data and report test health.
Progress0 / 4 steps
1
Create test result data
Create a list variable called builds with 3 dictionaries. Each dictionary should have keys build_number, passed, and failed with these exact values: build 1: passed 50, failed 5; build 2: passed 48, failed 7; build 3: passed 52, failed 3.
Jenkins
Need a hint?

Think of builds as a list of snapshots showing test results for each build.

2
Add a passing threshold
Add a variable called threshold and set it to 50. This will be the minimum number of passed tests to consider a build successful.
Jenkins
Need a hint?

This threshold helps decide if a build's test results are good enough.

3
Analyze test results with a loop
Use a for loop with variables build to go through each item in builds. Inside the loop, create a string status that is 'PASS' if build['passed'] is greater than or equal to threshold, otherwise 'FAIL'. Append a dictionary with keys build_number and status to a list called summary. Initialize summary as an empty list before the loop.
Jenkins
Need a hint?

Use a simple if-else inside the loop to decide the status for each build.

4
Print the test result trend summary
Write a print statement to display the summary list.
Jenkins
Need a hint?

Just print the summary list to see the trend.