Recall & Review
beginner
What is the purpose of
stash in Jenkins pipelines?stash saves files temporarily during a pipeline run so they can be used later in another stage or node.
Click to reveal answer
beginner
How does
unstash complement stash in Jenkins?unstash retrieves the files saved by stash so they can be used in a different stage or node.
Click to reveal answer
intermediate
Can
stash and unstash be used to pass data between parallel stages?Yes, stash and unstash allow sharing files between parallel or sequential stages in Jenkins pipelines.
Click to reveal answer
intermediate
What happens if you try to
unstash a name that was never stashed?Jenkins throws an error because it cannot find the stash with that name.
Click to reveal answer
beginner
Write a simple Jenkins pipeline snippet that stashes a file named
output.txt and then unstashes it in the next stage.stage('Save') {
steps {
writeFile file: 'output.txt', text: 'Hello'
stash name: 'myFiles', includes: 'output.txt'
}
}
stage('Use') {
steps {
unstash 'myFiles'
sh 'cat output.txt'
}
}Click to reveal answer
What does the
stash step do in Jenkins pipelines?✗ Incorrect
stash saves files temporarily so they can be accessed later using unstash.
Which step retrieves files saved by
stash?✗ Incorrect
unstash retrieves files saved by stash.
Can
stash and unstash be used across different nodes in a Jenkins pipeline?✗ Incorrect
stash and unstash enable passing files between different nodes.
What will happen if you try to
unstash a stash name that does not exist?✗ Incorrect
Jenkins throws an error because the stash name is not found.
Which of these is a correct way to stash all files in the workspace?
✗ Incorrect
Using includes: '**/*' stashes all files recursively.
Explain how
stash and unstash help pass data between stages in Jenkins pipelines.Think about how you might pack and unpack a suitcase to carry things between places.
You got /4 concepts.
Describe a scenario where using
stash and unstash is necessary in a Jenkins pipeline.Imagine you bake cookies in one kitchen and want to eat them in another kitchen.
You got /4 concepts.