I am using stash\unstash in my pipeline, and wondered could you unstash in multiple stages?
So for example:
stage('One') {
steps {
echo 'Stage one...'
stash includes: 'dist/**/*', name: 'builtSources'
dir('/some-dir/deploy') {
unstash 'builtSources'
}
}
}
stage('Two') {
steps {
echo 'Stage two...'
node('OtherNode') {
dir('/some-other-dir/deploy') {
unstash 'builtSources'
}
}
}
}
So can I retrieve a stash made in an earlier stage, in any of the following stages, any number of times?
stash : Stash some files to be used later in the buildSaves a set of files for later use on any node/workspace in the same Pipeline run. By default, stashed files are discarded at the end of a pipeline run.
You can skip stages in declarative pipelines using when , so the following should work. stages { stage('Deploy') { when { equals expected: true, actual: Deploy } steps { // ... } } }
Yes, you can definitely unstash the files multiple times across multiple stages and make the best use of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With