Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to disable deferred wipeout in the Jenkins workspace cleanup step.
Jenkins
steps {
cleanWs(disableDeferredWipeout: [1])
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
disableDeferredWipeout() or disableDeferredWipeout without ': true' causes a syntax error.
Using false keeps the default deferred wipeout behavior.
✗ Incorrect
The cleanWs step accepts disableDeferredWipeout: true to disable deferred deletion. Use the boolean true after the colon.
2fill in blank
mediumComplete the code to delete old builds after 10 days.
Jenkins
properties {
buildDiscarder(logRotator([1]: 10))
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using daysToKeepStr instead of daysToKeep causes type errors.
Using numToKeep controls number of builds, not days.
✗ Incorrect
The logRotator step uses daysToKeep to specify how many days to keep builds before deleting.
3fill in blank
hardFix the error in the code to archive artifacts only if they exist.
Jenkins
post {
always {
archiveArtifacts artifacts: '[1]', allowEmptyArchive: true
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a pattern that does not match existing files causes no artifacts archived.
Not setting allowEmptyArchive to true causes build failure if no files found.
✗ Incorrect
Using '**/*.log' archives all log files and allowEmptyArchive: true prevents errors if none exist.
4fill in blank
hardFill both blanks to configure disk usage cleanup with days and number of builds.
Jenkins
properties {
buildDiscarder(logRotator([1]: 7, [2]: 5))
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing artifactDaysToKeep with numToKeep causes unexpected behavior.
Using artifactNumToKeep instead of numToKeep affects artifacts, not builds.
✗ Incorrect
daysToKeep sets how many days to keep builds; numToKeep sets how many builds to keep.
5fill in blank
hardFill all three blanks to archive only jar files, keep 3 builds, and keep artifacts for 14 days.
Jenkins
properties {
buildDiscarder(logRotator([1]: 3, [2]: 14))
}
post {
success {
archiveArtifacts artifacts: '[3]'
}
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Confusing daysToKeep with artifactDaysToKeep.
Using wrong artifact pattern causes no files archived.
✗ Incorrect
numToKeep limits builds kept; artifactDaysToKeep limits artifact retention days; '**/*.jar' archives jar files.