Copy artifact within a jenkins pipeline

╄→гoц情女王★ 提交于 2019-12-03 04:06:56

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())
        )

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!