【发布时间】:2017-04-12 19:20:24
【问题描述】:
我有下面的 Jenkins 管道脚本来运行 jmeter 测试并从 JTL 文件中生成报告
node('master') {
stage 'Run JMeter Test'
def workspace = pwd()
def jmeterTestFile = 'jenkins_test'
echo "workspace = ${workspace}"
echo "env.WORKSPACE = ${env.WORKSPACE}"
bat "${workspace}\\jmeter\\bin\\jmeter.bat -n -t ${workspace}\\jmeter_scripts\\${jmeterTestFile}.jmx -l ${workspace}\\jmeter_scripts\\${jmeterTestFile}_results.jtl"
step([$class: 'ArtifactArchiver', artifacts: 'CP-Perf-Report.html,**/*.jtl, **/jmeter.log', fingerprint: true])
//perfReport "jmeter_scripts\\${jmeterTestFile}_results.jtl"
performanceReport parsers: [[$class: 'JMeterParser', glob: "jmeter_scripts\\${jmeterTestFile}_results.jtl"]], relativeFailedThresholdNegative: 1.2, relativeFailedThresholdPositive: 1.89, relativeUnstableThresholdNegative: 1.8, relativeUnstableThresholdPositive: 1.5
}
最初我尝试使用perfReport "jmeter_scripts\\${jmeterTestFile}_results.jtl" 命令创建报告,但使用FileNotFoundException 失败,所以我尝试使用performanceReport parsers 的替代方法,但即便如此,使用FileNotFoundException 再次失败,但我可以手动打开c:\tools\jenkins\workspace\PerformanceTesting\jmeter_scripts\jenkins_test_results.jtl 文件并查看测试报告。谁能帮我解决这个问题?
workspace = c:\tools\jenkins\workspace\PerformanceTesting
[Pipeline] echo
env.WORKSPACE = c:\tools\jenkins\workspace\PerformanceTesting
[Pipeline] step
Archiving artifacts
Recording fingerprints
[Pipeline] step
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
java.io.FileNotFoundException: c:\tools\jenkins\workspace\PerformanceTesting\jmeter_scripts\jenkins_test_results.jtl (The system cannot find the path specified)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileReader.<init>(Unknown Source)
at hudson.plugins.performance.parsers.ParserDetector.detect(ParserDetector.java:21)
at hudson.plugins.performance.parsers.ParserFactory.getParser(ParserFactory.java:26)
at hudson.plugins.performance.PerformancePublisher.getParsers(PerformancePublisher.java:439)
at hudson.plugins.performance.PerformancePublisher.perform(PerformancePublisher.java:481)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:69)
at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:59)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1$1.call(AbstractSynchronousNonBlockingStepExecution.java:52)
at hudson.security.ACL.impersonate(ACL.java:221)
at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Finished: FAILURE
【问题讨论】:
-
您确定需要使用\\.我在命令中使用 \。您可以查看此链接qainsights.com/integrate-apache-jmeter-jenkins
-
@NaveenKumarNamachivayam 是的,我需要使用 \\,因为它是 Jenkins Pipeline 作业中的一个 groovy 脚本
标签: jenkins groovy jmeter jmeter-plugins