【问题标题】:CucumberReportPublisher not working in pipeline jobCucumberReportPublisher 在管道作业中不工作
【发布时间】:2017-09-21 21:14:43
【问题描述】:

我正在使用 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 脚本的新手,有人可以帮助我在这里做错了什么,为什么这里没有生成黄瓜报告。

提前感谢您的帮助!

谢谢!

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

【问题讨论】:

    标签: jenkins dsl cucumber-jvm


    【解决方案1】:
    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 文件

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-18
      • 2016-11-07
      • 2015-10-28
      • 2018-01-01
      • 1970-01-01
      相关资源
      最近更新 更多