Artifact retention policies
📖 Scenario: You are managing a Jenkins pipeline that builds software projects. Each build produces artifacts like compiled files or reports. To save disk space, you want to keep only a limited number of recent artifacts and discard older ones automatically.
🎯 Goal: Set up a Jenkins pipeline script that defines artifact retention policies to keep only the last 3 builds' artifacts and discard older ones.
📋 What You'll Learn
Create a Jenkins pipeline script with a
pipeline blockAdd a
post section with always conditionUse
archiveArtifacts to save build artifactsUse
buildDiscarder with logRotator to keep only last 3 builds💡 Why This Matters
🌍 Real World
In real projects, managing disk space by cleaning old build artifacts is important to keep Jenkins servers healthy and fast.
💼 Career
Understanding artifact retention policies is essential for DevOps engineers to maintain CI/CD pipelines efficiently.
Progress0 / 4 steps