Log Management and Rotation with Jenkins
📖 Scenario: You are managing a Jenkins server that generates build logs. Over time, these logs can fill up disk space. To keep the server healthy, you want to set up log rotation to keep only recent logs and delete older ones automatically.
🎯 Goal: Set up a Jenkins job with log rotation configured to keep only the last 5 builds' logs. You will create a Jenkins pipeline script that defines this log rotation policy.
📋 What You'll Learn
Create a Jenkins pipeline script with a
pipeline blockAdd a
options block inside the pipelineConfigure
buildDiscarder with logRotator to keep 5 buildsPrint a message in the pipeline to confirm the job runs
💡 Why This Matters
🌍 Real World
Jenkins servers generate many build logs that can fill disk space. Managing logs by rotating and deleting old ones keeps the server healthy and fast.
💼 Career
DevOps engineers and build managers often configure Jenkins jobs to automatically clean up old logs, ensuring stable and efficient CI/CD pipelines.
Progress0 / 4 steps