`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
More on Declarative pipeline syntax
What is the minimum valid declarative pipeline?BeginnerWhat agent types exist in declarative pipelines?IntermediateWhen do you use `agent none` at the top level?IntermediateHow do nested sequential stages work and why are they useful?IntermediateList the `post` conditions and when each fires.IntermediateWhat are the most useful `when` conditions?Intermediate