I have a Jenkins pipeline.
In stage A, I have a step in which I need to archive or to save my artifacts because I need to reuse those in a different stage on a different slave:
stage('Save artifacts'){
steps {
archiveArtifacts artifacts: '**/**/target/app*.ear'
}
}
Archiving seems to work. I see the artifacts in the UI when the build finishes and can download them. But how can I access/download these artifacts in a later stage?
Instead of archiveArtifacts
you should use stash
and unstash
. E.g.:
stage("Build") {
steps {
// ...
stash(name: "ear", includes: '**/**/target/app*.ear')
}
}
stage("Deploy") {
steps {
unstash("ear")
// ...
}
}
Not that stash
does not only stash the files, but also their paths. So unstash
will put the files exactly in the same places they were (e.g. my-service/target/app.ear
).
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