当前位置:网站首页>Jenkins - data sharing and transfer between copy artifact plug-in builds
Jenkins - data sharing and transfer between copy artifact plug-in builds
2022-06-28 02:18:00 【wumingxiaoyao】
introduction
Realization CICD In the process of ,Jenkins Pipeline Job Build Need to transfer shared data between , such as , There is one Test Job Used to run test cases , After running, a test result file will be generated , Another one Report Job Is used to notify test results by email , Test result file is required , So you need to start with Test Job in Copy the test result file . Or for historical statistics , This time Build The results need to be based on the last Build Add new data to your data , Then you need to copy the previous one Build Results file for .Copy Artifact Plugin Can meet this demand , This article will introduce the plug-in .
Summary :
- Copy Artifact Plugin Introduction and installation
- Copy Artifact Plugin application
Copy Artifact Plugin Introduction and installation
Copy Artifact be applied to Jenkins Job Copy Archive the artifacts The archive , You can specify which Build ( for example :the last successful/stable build, by build number, or by a build parameter), You can also filter and control which files are copied and to which destination folder . Can also from workspace Directory copy file .
This plug-in is not available Jenkins The recommended plug-ins to install are listed in , So I want to use this plug-in , Separate installation required .
Manage Jenkins -> Plugin Manger
After successful installation , open Job Configure, Add build step You can see in the options Copy artifacts from another project
Copy Artifact Plugin application
File Archive the artifacts
Apply this Plugin Before , The shared files need to be archived . adopt Post-build Actions add to Archive the artifacts Options .

take workspace File in the directory , The files that have been successfully archived can be archived through URL To visit :JenkinsURL/…JobPath/BuildNo/artifact/
Copy artifacts from another project application
After filing , You can access the copy
For example, the following configuration , From the target job the last one build Copy all archived in the archive directory csv File to current Job Of workspace The root directory .

Build After success ,workspace You can see the copied file .

Here's a reminder , Default Job Configure in , Will delete workspace, If you need to keep workspace Don't check . To save storage space , It is suggested to check , It can be done by Arhicve the artifacts Archive some required documents .
Copy artifacts from another project Detailed settings
To the goal Build, There are many options , Some can be seen from their names , You can choose according to your needs .
Specific build Options
Give a specific example Build No Example , It can be accessed dynamically through variables .
Of course, it can also be Pipeline Groovy Script setting variables .
give an example : One Jenkins Pipeline Job, Parallel trigger Smoke and Regression Job, The final trigger Report job Mail notification , Parameters are passed to each other .
#!groovy
pipeline {
options {
buildDiscarder(logRotator(numToKeepStr: '15', daysToKeepStr: '15'))
}
agent {
label "Linux1" }
parameters {
string(name: 'branch', defaultValue: 'master', description: 'example : master')
string(name: 'env', defaultValue: 'dev', description: 'example : dev')
string(name: 'project_name', defaultValue: 'Project XXX', description: 'example : Project XXX')
string(name: 'email_list', defaultValue: '[email protected]',
description: 'example : [email protected]')
}
stages{
stage('Testing'){
parallel{
stage('Smoke') {
agent {
label "Linux1" }
steps {
script {
def smoke_build = build job: 'Smoke-Job',
propagate: false,
parameters: [
string(name: 'branch', value: "${params.branch}"),
string(name: "env", value: "${params.env}")
]
smoke_full_project_name = smoke_build.getFullProjectName()
smoke_build_num = smoke_build.getNumber()
}
}
}
stage('Regression') {
agent {
label "Linux1" }
steps {
script {
def regression_build = build job: 'Reg-Job',
propagate: false,
parameters: [
string(name: 'branch', value: "${params.branch}"),
string(name: "env", value: "${params.env}")
]
regression_full_project_name = regression_build.getFullProjectName()
regression_build_num = regression_build.getNumber()
}
}
}
}
}
}
post {
always {
build job: '../Report-JOB',
parameters: [
string(name: 'smoke_job', value: "${smoke_full_project_name}"),
string(name: 'smoke_build_num', value: "${smoke_build_num}"),
string(name: 'regression_job', value: "${regression_full_project_name}"),
string(name: 'regression_build_num', value: "${regression_build_num}"),
string(name: 'branch', value: "${params.branch}"),
string(name: 'env', value: "${params.env}"),
string(name: 'project_name', value: "${params.project_name}"),
string(name: 'email_list', value: "${params.email_list}")
]
}
}
}
Specified by a build parameter Options
First add a Build selector for Copy Artifact Parameters 
Copy arfifacts from another project, choice Specified by a build parameter Options , Parameter Name Directly fill in the previously added Build selector for Copy Artifact Parameter name is enough .
of Project Name and Permalink Parameters , Can be from Job Home page access .
Project Name Namely Full project name, You can avoid Job Identify problems between .
Permalink Parameters have been confused before , Later, I found that it was actually based on Job Fixation URL, At present Job You can see this information on the home page .
for example :lastBuild Of Permalinks
https://jenkinsURL/projectURL/lastBuild/

边栏推荐
猜你喜欢

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

How to optimize the "message" list of IM

类的初始化与回调的用法

fiddle如何使用代理

Drug interaction prediction based on learning size adaptive molecular substructure

mysql面试百题集

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

Class initialization and callback usage

The interviewer asked: can you simulate the new operator of JS

Xctf attack and defense world misc wage earner advanced zone
随机推荐
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩
Supervised, unsupervised and semi supervised learning
How to optimize the "message" list of IM
Adding text labels to cesium polygons the problem of polygon center point offset is solved
Numpy----np. meshgrid()
外盘期货哪里可以开户?哪个平台出入金比较安全?
OS module and os Learning of path module
Intensive reading of transformer thesis paragraph by paragraph
[sylixos] I2C device driver creation and use
Centos8 operation record command version Yum redis MySQL Nacos JDK
Database query optimization: master-slave read-write separation and common problems
Cesium 点击获取经纬度(二维坐标)
[Yocto RM] 2 - Yocto Project Terms
Scoped attribute and lang attribute in style
Differences between cesium polygon extrudedheight and height
OS模块与OS.path 模块的学习
Jenkins - access the Jenkins user-defined parameter variable, and handle the variable value containing spaces
数据库查询优化:主从读写分离及常见问题
[Yocto RM]9 - QA Error and Warning Messages