Copy artifact within a jenkins pipeline

后端 未结 3 731
生来不讨喜
生来不讨喜 2021-02-04 16:42

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         


        
3条回答
  •  粉色の甜心
    2021-02-04 17:29

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

提交回复
热议问题