gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 15:44:44 26 4
gpt4 key购买 nike

我正在尝试在 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"
    }
    }
  • 这是 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

    关于junit - 为什么 gitlab CI 找不到我的 junit 报告工件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56423038/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com