1 pipeline {
2 agent any
3
4
5 stages {
6 stage('reg') {
7 steps {
8 bat 'C:\Users\Administrator\Desktop\apache-jmeter-5.3\bin\jmeter.bat -n -t G:\AutomationTest\pipeline_test\reg.jmx -l G:\AutomationTest\pipeline_test\report\Jmeter-Result1.jtl'
9
10 bat 'G:\AutomationTest\pipeline_test\checkReport.bat'
11 }
12 }
13
14 stage('search') {
15 steps {
16 bat 'C:\Users\Administrator\Desktop\apache-jmeter-5.3\bin\jmeter.bat -n -t G:\AutomationTest\pipeline_test\search_user.jmx -l G:\AutomationTest\pipeline_test\report\Jmeter-Result2.jtl'
17 }
18 }
19
20 }
21 }
检查一下有没有失败的用例, 有失败,就返回1构建失败。没有失败就执行下一个步骤。 (麻烦就是变量不能用在bat里面,麻烦。。。。。。。。)
1 findstr /i "error" G:\AutomationTest\pipeline_test\report\Jmeter-Result1.jtl
2 if NOT %ERRORLEVEl% == 0 (
3 echo "无失败case"
4 exit 0 #然后再退出,jenkins就会报红显示构建失败
5
6 )else (
7 echo "有失败case"
8 exit 1 #然后再退出,jenkins就会报红显示构建失败
9 )
10 pause>nul