Jenkins:Copy Artifact

我们还在用 Jenkins 。。最近折腾了一下,做下简单记录。虽然 Jenkins 相对简单,但每次也难免去查。。

插件官方地址

https://plugins.jenkins.io/copyartifact/

简介

可以用Copy Artifact在不同节点/不同任务之间传递数据(Artifact)。

The plugin lets you specify which build to copy artifacts from (e.g. the last successful/stable build, by build number, or by a build parameter). You can also control the copying process by filtering the files being copied, specifying a destination directory within the target project, etc. Click the help icon on each field to learn the details, such as selecting Maven or multiconfiguration projects or using build parameters. You can also copy from the workspace of the latest completed build of the source project, instead of its artifacts. All artifacts copied are automatically fingerprinted for you.

该插件允许您指定从哪个构建中复制工件(例如,最后一个成功/稳定的构建,通过构建号或构建参数)。您还可以通过过滤正在复制的文件、指定目标项目中的目标目录等来控制复制过程。单击每个字段上的帮助图标了解详细信息,例如选择Maven或多配置项目或使用生成参数。您还可以从源项目的最新完成的构建的工作区中复制,而不是从其工件复制。所有复制的文物都会自动为你留下指纹。

使用

界面操作示例

pipeline 使用示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def branchname = "${BRANCH_NAME}".replace("/", "%2F")
pipeline {
agent {
label 'themachine'
}
stages {
stage('get artifacts') {
steps {
script {
parallel('get-backend': {
step([$class: 'CopyArtifact', projectName: "backend/${branchname}", target: 'input/backend'])
},
'get-frontend': {
step([$class: 'CopyArtifact', projectName: "frontend/${branchname}", target: 'input/frontend'])
})
}
}
}
}
}