CucumberReportPublisher不在管道作业中工作

时间:2017-04-25 02:55:36

标签: jenkins dsl cucumber-jvm

我正在使用Jenkins Pipeline工作来构建和运行单元测试,我的所有阶段都用groovy脚本编写,我在生成黄瓜报告时遇到异常:

[CucumberReport] Preparing Cucumber Reports
[CucumberReport] Copied 0 json files from workspace "/var/opt/jenkins/data/workspace/myJenkinsJob/${pwd()}/target/cucumber-html-report" to reports directory "/var/opt/jenkins/data/jobs/myJenkinsJob/builds/13/cucumber-html-reports/.cache"


java.lang.IllegalStateException: basedir /myJenkinsJOb/builds/13/cucumber-html-reports/.cache does not exist


    at org.apache.tools.ant.DirectoryScanner.scan(DirectoryScanner.java:879)
    at net.masterthought.jenkins.CucumberReportPublisher.findJsonFiles(CucumberReportPublisher.java:191)
    at net.masterthought.jenkins.CucumberReportPublisher.generateReport(CucumberReportPublisher.java:139)
    at net.masterthought.jenkins.CucumberReportPublisher.perform(CucumberReportPublisher.java:108)
    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:213)
    at org.jenkinsci.plugins.workflow.steps.AbstractSynchronousNonBlockingStepExecution$1.run(AbstractSynchronousNonBlockingStepExecution.java:49)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

请在下面找到我的DSL脚本:

stage "Publish Reports"
echo "***** Publish Reports *****"
def ReportPath = "${pwd()}/target/cucumber-html-report"
def JSONPath = "${pwd()}/target/cucumber-json-report.json"

step([$class: 'CucumberReportPublisher', 
            jsonReportDirectory: '${ReportPath}', 
            fileIncludePattern: '${JSONPath}'])

我是DSL脚本的新手,有人可以帮助我在这里做错了为什么黄瓜报告没有在这里生成。

提前感谢您的帮助!

谢谢!

注意:我们正在使用最新的黄瓜报告版本

1 个答案:

答案 0 :(得分:0)

stage "Publish Reports"
echo "***** Publish Reports *****"
def ReportPath = "${pwd()}/target/cucumber-html-report"
def JSONPath = "${pwd()}/target/cucumber-reports"

steps.step([$class: 'CucumberReportPublisher', 
        jsonReportDirectory: '${JSONPath}', 
        fileIncludePattern: '*.json'

因此,您必须在'jsonReportDirectory'中提供json根路径,文件模式应为'.json'

'CucumberReportPublisher'类本身会查找jsonReportDirectory中存在的所有.json文件

相关问题