junit - 为什么gitlab CI找不到我的junit报告神器?
问题描述
我正在尝试在 Gitlab CI 上上传 J-unit 报告(这些是我的赛普拉斯自动化框架的测试结果)。我正在使用 Junit 合并。由于赛普拉斯的体系结构(每个测试都是独立的),它需要额外的“合并”报告才能将它们放入一个文件中。本地evertything工作正常:
- Junit 使用哈希码生成每个测试的单个报告
- 生成所有报告后,我运行一个脚本(如下所示),将所有报告混合到一个 .xml 文件中,并将其输出到“结果”包下方。
试图在本地调试它,但在本地一切正常。我能想到的可能性:合并脚本没有正确处理,或者 Gitlab 不接受 .xml 文件的相对路径。
{
"baseUrl": "https://www-acc.anwb.nl/",
"reporter": "mocha-junit-reporter",
"reporterOptions": {
"mochaFile": "results/resultsreport.[hash].xml",
"testsuiteTitle": "true"
}
}
- 这是 Cypress.json 文件,我在其中配置了 Junit 报告器并让它在结果包中输出单个测试文件。
赛普拉斯-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
- 这是 yml 文件的一部分。npx junit-merge 命令确保结果包中的所有 .xml 文件都被合并到 results.xml 中。
同样,本地一切都按预期工作。我从 gitlab Ci 得到的错误是:
Uploading artifacts...
WARNING: results/results.xml: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1
解决方案
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
推荐阅读
- cython - ImportError:在 readthedocs 服务器上安装要求时没有名为“Cython”的模块
- java - 获取 List 中元素的类型
- gitlab - 如何恢复默认的 gitlab 页面?
- javascript - 为什么“this”关键字不是指我设置的状态?
- assembly - 分装 TASM
- python-3.x - 为什么python从pdf中提取符号而不是文本
- gerrit - 减少 Gerrit 发送的电子邮件通知数量
- python - 将 collections.Counter() 与具有负整数的 Django 查询集一起使用
- odoo - 如何在 Odoo11 的 POS 屏幕上添加按钮?
- dafny - Dafny 中的琐碎断言违规