0
0
Jenkinsdevops~20 mins

Artifact retention policies in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Artifact Retention Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding artifact retention in Jenkins

What is the primary purpose of setting artifact retention policies in Jenkins?

ATo automatically delete old build artifacts to save disk space
BTo speed up the build process by caching artifacts
CTo increase the number of builds stored indefinitely
DTo prevent any build artifacts from being deleted
Attempts:
2 left
💡 Hint

Think about why disk space might be limited on build servers.

💻 Command Output
intermediate
2:00remaining
Effect of artifact retention configuration in Jenkinsfile

Given the following Jenkinsfile snippet, what will be the number of builds with artifacts retained after 10 builds?

Jenkins
pipeline {
  agent any
  options {
    buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '3'))
  }
  stages {
    stage('Build') {
      steps {
        echo 'Building...'
      }
    }
  }
}
ANo builds will have artifacts retained
B5 builds will have artifacts retained
CAll 10 builds will have artifacts retained
D3 builds will have artifacts retained
Attempts:
2 left
💡 Hint

Look at the artifactNumToKeepStr value.

Configuration
advanced
2:00remaining
Configuring artifact retention via Jenkins UI

Which configuration in Jenkins UI correctly sets artifact retention to keep artifacts for the last 7 builds only?

AIn the job configuration, under 'Build Environment', enable 'Discard old builds' and set 'Max # of artifacts to keep' to 7
BIn the job configuration, under 'Discard old builds', set 'Max # of builds to keep' to 7 and 'Max # of artifacts to keep' to 7
CIn the job configuration, under 'Discard old builds', set 'Max # of builds to keep' to 7 and leave 'Max # of artifacts to keep' empty
DIn the job configuration, under 'Build Triggers', enable 'Discard old builds' and set 'Max # of builds to keep' to 7
Attempts:
2 left
💡 Hint

Artifact retention requires both builds and artifacts limits to be set.

Troubleshoot
advanced
2:00remaining
Troubleshooting artifact retention not working

A Jenkins job is configured to discard old builds and artifacts, but artifacts are not being deleted as expected. What is the most likely cause?

AThe Jenkins master has insufficient disk space
BThe artifacts are stored on a network share that Jenkins cannot access
CThe job is using a pipeline script without a <code>buildDiscarder</code> option configured
DThe job has no post-build actions configured
Attempts:
2 left
💡 Hint

Retention settings in pipeline scripts require explicit configuration.

Best Practice
expert
2:30remaining
Best practice for artifact retention in large Jenkins environments

In a large Jenkins environment with many jobs producing large artifacts, what is the best practice to manage artifact retention efficiently?

AUse centralized artifact storage with lifecycle policies and configure Jenkins to discard local artifacts quickly
BKeep all artifacts indefinitely on Jenkins master to avoid losing any data
CDisable artifact retention and manually delete artifacts weekly
DConfigure each job to keep artifacts for at least 100 builds to ensure availability
Attempts:
2 left
💡 Hint

Think about scalability and automation in managing storage.