首页 > 解决方案 > 为什么gitlab CI找不到我的junit报告神器?

问题描述

我正在尝试在 Gitlab CI 上上传 J-unit 报告(这些是我的赛普拉斯自动化框架的测试结果)。我正在使用 Junit 合并。由于赛普拉斯的体系结构(每个测试都是独立的),它需要额外的“合并”报告才能将它们放入一个文件中。本地evertything工作正常:

试图在本地调试它,但在本地一切正常。我能想到的可能性:合并脚本没有正确处理,或者 Gitlab 不接受 .xml 文件的相对路径。

{
  "baseUrl": "https://www-acc.anwb.nl/",

  "reporter": "mocha-junit-reporter",

  "reporterOptions": {

    "mochaFile": "results/resultsreport.[hash].xml",

    "testsuiteTitle": "true"
  }
}

赛普拉斯-e2e:

image: cypress/base:10

stage: test

script:

- npm run cy:run:staging

- npx junit-merge -d results -o results/results.xml

artifacts:

 paths:

 - results/results.xml

 reports:

  junit: results/results.xml

 expire_in: 1 week

同样,本地一切都按预期工作。我从 gitlab Ci 得到的错误是:

Uploading artifacts...
WARNING: results/results.xml: no matching files    
ERROR: No files to upload                          
ERROR: Job failed: exit code 1

标签: junitcontinuous-integrationgitlabcypress

解决方案


Artifacts can only exist in
directories relative to the build directory and specifying paths which don't
comply to this rule trigger an unintuitive and illogical error message (an
enhancement is discussed at
gitlab-ce#15530
). Artifacts need to be uploaded to the GitLab instance (not only the GitLab
runner) before the next stage job(s) can start, so you need to evaluate
carefully whether your bandwidth allows you to profit from parallelization
with stages and shared artifacts before investing time in changes to the
setup.

https://gitlab.com/gitlab-org/gitlab-ee/tree/master/doc/ci/caching

这意味着下一个配置应该可以解决问题:

artifacts:

 reports:

  junit: <testing-repo>/results/results.xml

 expire_in: 1 week

推荐阅读