当前位置:网站首页>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/
边栏推荐
- How fiddle uses agents
- Capacitor
- 指南针股票开户是会有什么风险吗?指南针开户安全吗
- Adobe Premiere基础-常用的视频特效(裁剪,黑白,剪辑速度,镜像,镜头光晕)(十五)
- Overview of drug discovery-01 overview of drug discovery
- Adobe Premiere Basics - common video effects (corner positioning, mosaic, blur, sharpen, handwriting tools, effect control hierarchy) (16)
- How to optimize the "message" list of IM
- Database query optimization: master-slave read-write separation and common problems
- Centos8 operation record command version Yum redis MySQL Nacos JDK
- Jenkins - Pipeline concept and creation method
猜你喜欢
Cesium Click to draw polygons (dynamically draw polygons)
Numpy----np.tile()函数解析
frp实现内网穿透
Appium automation test foundation - Supplement: app package name and appactivity
Jenkins - 邮件通知 Email Notification 插件
TI AM3352/54/59 工业核心板硬件说明书
766. toplitz matrix
将某数据库N多表名作为另外一张表中某一列得值(范围可以是别的数据库中得某张表)
【永艺XY椅】试用体验
Drug interaction prediction based on learning size adaptive molecular substructure
随机推荐
[embedded foundation] serial port communication
[Niuke discussion area] Chapter 4: redis
Ten MySQL locks, one article will give you full analysis
[Yocto RM] 4 - Source Directory Structure
To understand what is synchronous, asynchronous, serial, parallel, concurrent, process, thread, and coroutine
[Yongyi XY chair] trial experience
style中的scoped属性和lang属性
Jenkins - built in variable access
Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
Machine learning notes - time series as features
Chapitre 4: redis
TD Hero online conference on July 2
数据库的新选择 Amazon Aurora
数据库查询优化:主从读写分离及常见问题
面试官问:能否模拟实现JS的new操作符
Appium automation test foundation ADB common commands (I)
Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
Jenkins - Pipeline syntax
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Where can I open an account for foreign exchange futures? Which platform is safer for cash in and out?