What is the primary purpose of setting artifact retention policies in Jenkins?
Think about why disk space might be limited on build servers.
Artifact retention policies help manage disk space by removing old or unnecessary build files automatically.
Given the following Jenkinsfile snippet, what will be the number of builds with artifacts retained after 10 builds?
pipeline {
agent any
options {
buildDiscarder(logRotator(numToKeepStr: '5', artifactNumToKeepStr: '3'))
}
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
}Look at the artifactNumToKeepStr value.
The artifactNumToKeepStr controls how many builds keep their artifacts. Here it is set to 3, so only the latest 3 builds keep artifacts.
Which configuration in Jenkins UI correctly sets artifact retention to keep artifacts for the last 7 builds only?
Artifact retention requires both builds and artifacts limits to be set.
To keep artifacts for the last 7 builds, both 'Max # of builds to keep' and 'Max # of artifacts to keep' must be set to 7 under 'Discard old builds'.
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?
Retention settings in pipeline scripts require explicit configuration.
In pipeline jobs, artifact retention must be explicitly set using the buildDiscarder option; otherwise, Jenkins will not discard old artifacts automatically.
In a large Jenkins environment with many jobs producing large artifacts, what is the best practice to manage artifact retention efficiently?
Think about scalability and automation in managing storage.
Centralized artifact storage with lifecycle policies offloads storage from Jenkins master and automates retention, improving scalability and reliability.