0
0
Jenkinsdevops~20 mins

Log management and rotation in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Log Rotation Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Jenkins log rotation configuration effect
Given this Jenkins pipeline snippet for log rotation:
properties([
  buildDiscarder(logRotator(numToKeepStr: '5', daysToKeepStr: '10'))
])

What is the effect on the build logs?
AJenkins keeps only the last 10 builds and deletes logs older than 5 days.
BJenkins keeps only the last 5 builds and deletes logs older than 10 days.
CJenkins deletes all logs immediately after build completion.
DJenkins keeps all builds but deletes logs older than 10 days.
Attempts:
2 left
💡 Hint
Look at the parameters numToKeepStr and daysToKeepStr carefully.
🧠 Conceptual
intermediate
1:30remaining
Purpose of Jenkins log rotation
Why is log rotation important in Jenkins?
ATo prevent disk space from filling up by old build logs.
BTo speed up build execution by caching logs.
CTo encrypt logs for security reasons.
DTo automatically restart Jenkins after each build.
Attempts:
2 left
💡 Hint
Think about what happens if logs keep growing without limit.
Configuration
advanced
2:30remaining
Correct Jenkinsfile snippet for log rotation
Which Jenkinsfile snippet correctly configures log rotation to keep 7 builds and logs for 14 days?
Aproperties([buildDiscarder(logRotator('7', '14'))])
Bproperties([buildDiscarder(logRotator(numToKeep: 7, daysToKeep: 14))])
Cproperties([buildDiscarder(logRotator(numToKeepStr: '7', daysToKeepStr: '14'))])
Dproperties([buildDiscarder(logRotator(numToKeep: '7', daysToKeepStr: 14))])
Attempts:
2 left
💡 Hint
Check the parameter names and their types carefully.
Troubleshoot
advanced
2:30remaining
Jenkins log rotation not deleting old logs
You configured Jenkins with:
properties([
  buildDiscarder(logRotator(numToKeepStr: '3', daysToKeepStr: '5'))
])

But old logs are not deleted after 5 days. What is the most likely cause?
AThe Jenkins master does not have permission to delete old log files.
BThe numToKeepStr parameter should be an integer, not a string.
CThe logRotator plugin is not installed in Jenkins.
DThe daysToKeepStr parameter only works for freestyle jobs, not pipelines.
Attempts:
2 left
💡 Hint
Consider file system permissions for Jenkins.
Best Practice
expert
3:00remaining
Best practice for managing Jenkins logs in large environments
In a large Jenkins environment with many builds daily, what is the best practice for managing logs to ensure performance and disk space?
AIncrease disk space indefinitely to avoid deleting logs.
BDisable log rotation to keep all logs for audit purposes.
CManually delete logs weekly using shell scripts without Jenkins configuration.
DUse log rotation with reasonable limits and archive important logs to external storage.
Attempts:
2 left
💡 Hint
Think about automation and long-term storage.