But artifacts are not deleted after 10 days. What is the likely problem?
medium
A. logRotator does not support artifact retention
B. The buildDiscarder option must be inside stages
C. You must use archiveArtifacts to delete old artifacts
D. The parameter name should be artifactDaysToKeepStr, not artifactDaysToKeep
Solution
Step 1: Check logRotator parameter names
logRotator parameters for strings end with 'Str', like artifactDaysToKeepStr.
Step 2: Identify the syntax issue
Missing 'Str' means the parameter is not recognized, so default retention applies and artifacts aren't deleted after 10 days.
Final Answer:
The parameter name should be artifactDaysToKeepStr, not artifactDaysToKeep -> Option D
Quick Check:
logRotator params end with 'Str' [OK]
Hint: logRotator params like artifactDaysToKeepStr end with Str [OK]
Common Mistakes:
Using wrong parameter names
Expecting logRotator to delete artifacts
Placing buildDiscarder outside options block
5. You want to keep artifacts only for the last 4 builds and delete older artifacts automatically, while keeping older builds. Which Jenkins pipeline snippet correctly applies this retention policy?
D. steps { archiveArtifacts artifacts: '**/*', keepOnlyLast: 4 }
Solution
Step 1: Understand roles for artifact-specific retention
To keep artifacts from only the last 4 builds while retaining builds, use artifactNumToKeepStr.
Step 2: Check option correctness
options { buildDiscarder(logRotator(artifactNumToKeepStr: '4')) }: buildDiscarder(logRotator(artifactNumToKeepStr: '4')) keeps artifacts from last 4 builds, deletes older artifacts, keeps all builds. C deletes old builds too. B/D use invalid params.
Final Answer:
options { buildDiscarder(logRotator(artifactNumToKeepStr: '4')) } -> Option B
Quick Check:
artifactNumToKeepStr for artifacts only [OK]
Hint: artifactNumToKeepStr keeps artifacts from last N builds [OK]
Common Mistakes:
Using invalid parameters like retentionDays or keepOnlyLast
Trying to control retention only via archiveArtifacts
Misplacing buildDiscarder outside options block
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.