提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、持续集成git目录结构
Postman/*.json | 存放脚本 |
---|---|
config/*.json | 存放environment环境变量 |
Jenkinsfile | 流水线脚本 |
x.sh | 其他辅助型shell脚本 |
json/* | ---- |
一、Jenkinsfile编写
pipeline{
agent {label 'master'}
environment {
# 初始环境变量文件
initialEnvironment = './config/x.environment.json'
# 运行中覆盖写入
runningEnvironment = './config/x.environment.json'
aj_data = "1"
}
stages {
stage('01_进入APP'){
steps{
script {
catchError(buildResult:'FAILURE',stageResult:'FAILURE',catchInterruptions:true,message:'TEST'){
sh 'newman run ./Postman/01_进入APP.postman_collection.json -e ${initialEnvironment} --export-environment ${runningEnvironment} -r junit,cli,html --reporter-junit-export ./result/01_进入APP_reprot.xml --reporter-html-export ./result/01_进入APP_reprot.html'
}
}
}
}
stage('02_获取数据'){
# 判断,如果values匹配成功,则执行step内容
when{
environment name: 'aj_data',
value: '1'
}
steps{
script {
catchError(buildResult:'FAILURE',stageResult:'FAILURE',catchInterruptions:true,message:'TEST'){
sh 'newman run ./Postman/02_后获取数据.postman_collection.json -e ${initialEnvironment} --export-environment ${runningEnvironment} -r junit,cli,html --reporter-junit-export ./result/02_获取数据_reprot.xml --reporter-html-export ./result/02_获取数据_reprot.html'
}
}
}
}
}
}