I have a Jenkins pipeline job that archives an Artifact in its first phase, I then need to copy that Artifact in another stage of the pipeline build
node {
sta
In pipeline plugin, there is a new feature called 'stash', 'unstash' instead of artifacts.
Artifact: Archives are designed for longer term file storage (e.g., intermediate binaries from your builds). Artifact requires more storage space and resource management.
Stash: Saves a set of files and use later in the same build, generally on another node/workspace. stash and unstash steps are designed for use with small files. Stash/unstash can be used inside a pipeline with just assigning a name to the stash & works only locally.
Here is a good example for stash/unstash: Tutorial
Figured this one out, so using the var ${BUILD_NUMBER} you can access artifacts un the current pipeline
step([$class: 'CopyArtifact', filter: 'build/test.js', fingerprintArtifacts: true, flatten: true, projectName: 'echo-develop-js-pipeline', selector: [$class: 'SpecificBuildSelector', buildNumber: '${BUILD_NUMBER}'], target: './client/public/vendor/echo/'])
I needed this recently, and none of the other solutions here did exactly what I wanted, because I need to use multiple parameter filters for my selection. Here's what I did using the "Run Selector Plugin" in addition to the direct calling of the "Copy Artifact Plugin":
Step One: Select the build number you need.
prereq_build = selectRun filter: parameters("TARGET_OS=${TARGET_OS},GIT_BRANCH_NAME=${GIT_BRANCH_NAME}"), job: 'prereq_rpms', selector: status('STABLE'), verbose: true
Step Two: Copy (updated 2017-11: Native pipeline support now!).
copyArtifacts(
projectName: 'prereq_rpms',
filter: '**/*.rpm',
fingerprintArtifacts: true,
target: 'prereq',
flatten: true,
selector: specific(prereq_build.getId())
)