Interview Prep/Jenkins/Declarative pipeline syntax

`stash`/`unstash` vs `archiveArtifacts`: when do you use each?

IntermediateConceptDeclarative pipeline syntax
Answer

stash saves files to the controller for use later in the same build, typically to move build output between agents; stashes are discarded at build end. archiveArtifacts keeps files with the build record for download after the build. Both pass data through the controller, so neither suits large binaries: push packages to Nexus/Artifactory and images to a registry instead.

stash name: 'dist', includes: 'dist/**'
unstash 'dist'
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
All Jenkins questions Roadmap: Jenkins

More on Declarative pipeline syntax