pipeline {
agent any
environment {
name="${JOB_NAME}"
times="${currentBuild.duration}"
task="${BUILD_ID}"
logs="${ChangeLog}"
}
stages {
stage('拉取代码') {
steps {
git credentialsId: '3', url: '[email protected]:tps-qa/test/matrix-autotest.git'
}
}
// 这里的install plug-in 是我加的,就是说明,这是stages下的第二个任务 ,就是在pipeline中加单行注释 用 // 就行
stage('install plug-in') {
steps {
echo '开始安装插件'
sh 'pip3 install -r requirements.txt'
echo '插件安装完成'
}
}
stage('execute auth_system Test') {
steps {
echo '开始执行鉴权系统测试'
sh 'python3 Run/main.py --system_style Authen_style'
echo '执行测试完成'
}
}
stage('execute device_system Test') {
steps {
echo '开始执行接入系统测试'
sh 'python3 Run/main.py --system_style device_style'
echo '执行测试完成'
}
}
stage('execute data_system Test') {
steps {
echo '开始执行数据系统测试'
sh 'python3 Run/main.py --system_style data_style'
echo '执行测试完成'
}
}
stage('execute info_system Test') {
steps {
echo '开始执行信息系统测试'
sh 'python3 Run/main.py --system_style info_style'
echo '执行测试完成'
}
}
stage('execute vehicle_monitor_system Test') {
steps {
echo '开始执行重点车监管系统测试'
sh 'python3 Run/main.py --system_style monitor_style'
echo '执行测试完成'
}
}
stage('execute general_monitor_system Test') {
steps {
echo '开始执行综合监管测试'
sh 'python3 Run/main.py --system_style general_monitor'
echo '执行测试完成'
}
}
stage('execute cloud_3d_system Test') {
steps {
echo '开始执行3D系统测试'
sh 'python3 Run/main.py --system_style cloud_3d_system'
echo '执行测试完成'
}
}
stage('Test port') {
steps {
echo '生成报告中.........'
//sh 'cd ${workspace}'
allure includeProperties: false, jdk: '', reportBuildPolicy: 'ALWAYS', report: 'logs/report/report_html', results: [[path: 'logs/report/json_file']]
echo '报告生成完成'
}
}
}
post {
success {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c927aa95-aef7-4630-8aa6-b94f78ba1525' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建成功 ✅:'$name'项目! \n
>### 持续时间:'$times'
>### 用户名/密码: user/user
>### [<<< 点击查看报告 >>>]('http://10.4.196.81:8080/jenkins/job/Matrix-autotest/$task/allure')"
}
}'
'''
}
failure {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c927aa95-aef7-4630-8aa6-b94f78ba1525' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建失败 ❌'$name'项目! \n
>### 持续时间:'$times'
>### 用户名/密码: user/user
>### [<<< 点击查看报告 >>>]('http://10.4.196.81:8080/jenkins/job/Matrix-autotest/$task/allure')"
}
}'
'''
echo 'failure'
}
unstable {
sh '''
curl 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=c927aa95-aef7-4630-8aa6-b94f78ba1525' \
-H 'Content-Type: application/json' \
-d '
{
"msgtype": "markdown",
"markdown": {
"content": "#### 构建不稳定,出现部分异常 ❌'$name'项目! \n
>### 持续时间: '$times'
>### 用户名/密码: user/user
>### [<<< 点击查看报告 >>>]('http://10.4.196.81:8080/jenkins/job/Matrix-autotest/$task/allure')"
}
}'
'''
echo 'unstable'
}
}
}
标签:style,微信,system,sh,echo,Allure,steps,Jenkins,stage
From: https://www.cnblogs.com/yanjiahong/p/17693859.html