What is the difference between `stash/unstash` and `archiveArtifacts`?
IntermediateConceptJenkins
Answer
stash saves files temporarily to the controller during a run so another stage on a different agent can unstash them; stashes disappear when the build ends and should be small. archiveArtifacts stores files permanently with the build record so people and other jobs can download them later. For anything large, use an artifact repository or object storage rather than either, because both route data through the controller.
stash name: 'jar', includes: 'target/*.jar'
// later, on another agent
unstash 'jar'
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
More on Jenkins
What is Jenkins and how is its architecture organised?BeginnerWhat are executors, nodes and labels in Jenkins?IntermediateWhy should you not run builds on the Jenkins controller?BeginnerHow do inbound (JNLP/WebSocket) and SSH agents connect to the controller?IntermediateWhat is a Jenkinsfile and where does it live?BeginnerDeclarative versus Scripted Pipeline: what are the differences?Intermediate