Jenkins管道中的Jmeter报告生成中出现空指针异常

kiz8lqtg  于 2022-11-09  发布在  Jenkins
关注(0)|答案(1)|浏览(325)

我正在Jenkins管道中以非GUI模式运行jmeter测试。
以下是其他版本:

Jenkins agent java vaerion : 11
Jmeter version : 5.3

我在Jenkins中运行的命令

/home/jenkins/jmeter/apache-jmeter-5.1/bin/jmeter.sh -f -n -t jmeter_scripts/Suite_master.jmx -l output.jtl -j jmeter.log -p project.properties -e -o results

但是,我在生成HTML结果文件时看到以下失败

2022-04-29 02:05:29,397 INFO o.a.j.r.p.CsvFileSampleSource: produce(): 1086 samples produced in 66ms on channel 0
2022-04-29 02:05:29,397 INFO o.a.j.r.d.ReportGenerator: Exporting data using exporter:'json' of className:'org.apache.jmeter.report.dashboard.JsonExporter'
2022-04-29 02:05:29,399 INFO o.a.j.r.d.JsonExporter: Found data for consumer statisticsSummary in context
2022-04-29 02:05:29,399 INFO o.a.j.r.d.JsonExporter: Creating statistics for overall
2022-04-29 02:05:29,399 ERROR o.a.j.JMeter: Error generating the report
java.lang.NullPointerException: null
    at org.apache.jmeter.report.dashboard.JsonExporter.createStatistic(JsonExporter.java:121) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.JsonExporter.export(JsonExporter.java:71) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.ReportGenerator.exportData(ReportGenerator.java:381) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.report.dashboard.ReportGenerator.generate(ReportGenerator.java:262) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.JMeter$ListenToTest.generateReport(JMeter.java:1324) ~[ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.JMeter$ListenToTest.testEnded(JMeter.java:1261) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.engine.StandardJMeterEngine.notifyTestListenersOfEnd(StandardJMeterEngine.java:218) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at org.apache.jmeter.engine.StandardJMeterEngine.run(StandardJMeterEngine.java:492) [ApacheJMeter_core.jar:5.1.1 r1855137]
    at java.lang.Thread.run(Unknown Source) [?:?]
[Pipeline] sh

顺便说一句,我可以看到jtl文件的数据以及

-rw-r--r--. 1 jenkins jenkins 273418 Apr 29 02:05 output.jtl
ygya80vv

ygya80vv1#

您的project.properties文件是否包含生成报告(如jmeter.reportgenerator.apdex_satisfied_thresholdjmeter.reportgenerator.apdex_tolerated_threshold)绝对需要的属性?
如果没有,请确保它们在那里,并包含所需的值。
如果您想传递一组project属性,替换原始的 jmeter.properties 文件并不是最好的方法,因为除了前面提到的与 Jmeter 板相关的属性之外,它还有几个默认值,如果缺少这些默认值,可能会导致意外行为。
因此,我建议保持jmeter.properties不变,并使用-q命令行参数将自定义属性集传递给JMeter

/home/jenkins/jmeter/apache-jmeter-5.1/bin/jmeter.sh -f -n -t jmeter_scripts/Suite_master.jmx -l output.jtl -j jmeter.log -q project.properties -e -o results

更多信息:

相关问题