Disk space management
📖 Scenario: You are a Jenkins administrator. Your Jenkins server stores many build artifacts and logs. Over time, disk space fills up, causing build failures. You want to manage disk space by cleaning old builds automatically.
🎯 Goal: Build a Jenkins pipeline script that defines a workspace cleanup strategy. You will create a list of build directories, set a threshold for maximum builds to keep, delete older builds beyond the threshold, and print the cleanup result.
📋 What You'll Learn
Create a list of build directories as strings
Define a maximum number of builds to keep as an integer
Write a loop to delete builds older than the threshold
Print the list of builds remaining after cleanup
💡 Why This Matters
🌍 Real World
Jenkins servers accumulate many build artifacts and logs. Managing disk space by cleaning old builds prevents failures and keeps the server healthy.
💼 Career
DevOps engineers and Jenkins administrators often write scripts to automate disk space management and maintain continuous integration environments.
Progress0 / 4 steps