当前位置:网站首页>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/

边栏推荐
- Jenkins - Pipeline syntax
- Jenkins - Pipeline concept and creation method
- Chapitre 4: redis
- Numpy----np.meshgrid()
- JS 随机数(随机数 小数)
- Cesium color color (assignment) random color
- JS array random value (random array value)
- frp实现内网穿透
- 766. 托普利茨矩阵
- What problems should be evaluated before implementing MES management system
猜你喜欢

Appium自动化测试基础 — ADB常用命令(一)

Cesium 多边形(polygon)extrudedHeight 和 height 的区别

【ELT.ZIP】OpenHarmony啃论文俱乐部—数据密集型应用内存压缩

数据库的新选择 Amazon Aurora

Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)

Jenkins - 邮件通知 Email Notification 插件

Class initialization and callback usage

Hi, you have a code review strategy to check!

Cesium obtains the latitude and longitude range of the screen

利用redis bitmap实现人员在线情况监控
随机推荐
数据库的新选择 Amazon Aurora
Evaluation - rank sum ratio comprehensive evaluation
面试官问:能否模拟实现JS的new操作符
Appium automation test foundation - Supplement: app package name and appactivity
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
TI AM3352/54/59 工业核心板硬件说明书
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
Machine learning notes - time series as features
pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
Capacitor
Appium自动化测试基础— 补充:App的包名(appPackage)和启动名(appActivity)
geojson 格式说明(格式详解)
Description du format geojson (détails du format)
Fundamentals of scala (3): operators and process control
指南针股票开户是会有什么风险吗?指南针开户安全吗
Prometeus 2.35.0 新特性
Cesium 多边形(polygon)extrudedHeight 和 height 的区别
Jenkins - 訪問 Jenkins 自定義參數變量,處理變量值中含有空格
Lmsoc: a socially sensitive pre training method