为什么 gitlab CI 找不到我的 junit 报告工件?

tij*_*ter 5 junit continuous-integration gitlab cypress

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

  • Junit 使用哈希码生成每个测试的单个报告
  • 生成所有报告后,我运行一个脚本(如下所示),将所有报告混合到一个 .xml 文件中,并将其输出到“结果”包下方。

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

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

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

  "reporterOptions": {

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

    "testsuiteTitle": "true"
  }
}
Run Code Online (Sandbox Code Playgroud)
  • 这是 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
Run Code Online (Sandbox Code Playgroud)
  • 这是 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
Run Code Online (Sandbox Code Playgroud)

Ana*_*ova 3

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.
Run Code Online (Sandbox Code Playgroud)

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

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

artifacts:

 reports:

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

 expire_in: 1 week
Run Code Online (Sandbox Code Playgroud)