在詹金斯管道中复制工件 [英] Copy artifact within a jenkins pipeline

查看:118
本文介绍了在詹金斯管道中复制工件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Jenkins管道作业,该阶段在第一阶段存档了Artifact,然后我需要在管道构建的另一个阶段复制该Artifact

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 {
  stage 'Stage 1 of build'
  // Run tests, if successful archive the artifact
  archiveArtifacts artifacts: 'build/test.js', excludes: null
 stage 'Stage 2 of build'
 // want to copy artifact from stage 1 of the build
 step([$class: 'CopyArtifact', filter: 'build/test.js', fingerprintArtifacts: true, flatten: true, projectName: 'echo-develop-js-pipeline', selector: [$class: 'WorkspaceSelector'], target: './client/public/vendor/echo/'])
}

有了这个,我得到一个unable to find a build for artifact copy

With this I get a unable to find a build for artifact copy

创建工件后,将其保存在此处:

When the artifact is created it is saved here:

http://localhost:8181/view/Echo JS Develop/job/echo-develop-js-pipeline/233/artifact/build/test.js

如何在管道作业中访问创建的工件?

How do I access the created artifact from within a pipeline job?

推荐答案

解决了这个问题,因此使用var $ {BUILD_NUMBER}可以访问当前管道中的工件

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/'])

这篇关于在詹金斯管道中复制工件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆