gpt4 book ai didi

docker - Newman 报告生成在本地工作,但不是来自 CI

转载 作者:行者123 更新时间:2023-12-02 19:21:57 28 4
gpt4 key购买 nike

我有一个 GitLab CI 作业,它使用自定义环境运行一系列 Postman 请求。我正在使用 Newman 将它们与 newman-reporter-htmlextra 一起运行生成测试报告的 npm 插件。

作业如下所示:

postman-tests:
stage: postman-tests
image:
name: wojciechzurek/newman-ci
before_script:
- cd ci/tests/postman
- npm install -g newman-reporter-htmlextra
script:
- newman run Non-regression_tests.postman_collection.json -e Tests.postman_environment.json \
--reporters htmlextra --reporter-htmlextra-export newman-results.html
- ls -la # Check report generation
artifacts:
when: always
paths:
- newman-results.html
allow_failure: true

当我在我的 mac (newman 4.5.0) 上运行 newman 时,请求和相关测试正常运行并生成报告。但是,作业失败并且未生成报告:

 $ newman run Non-regression_tests.postman_collection.json -e Tests.postman_environment.json --reporters htmlextra --reporter-htmlextra-export newman-results.html --color

Uploading artifacts...

WARNING: newman-results.html: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1

看来问题可能是由测试系列本身而不是报告生成引起的,因为即使我不生成报告,作业也会失败。

我尝试了不同的运行器:带有官方 newman 图像的 Docker、SSH 和 shell 在我预先安装了 newman(版本 4.5.6)和 htmlextra 报告器的机器上。全部失败。
有趣的是,测试系列和报告生成在 SSH 和 shell 运行器后面的机器上本地运行时都成功,但从 GitLab CI 启动时它们确实失败了。

我忘记/做错了什么阻止了 GitLab CI 生成测试报告?

最佳答案

我的 .yml 用于测试,看起来像这样 - 它非常基本,但我刚刚再次运行它并且运行良好:

stages:
- test

newman_tests:
stage: test
image:
name: postman/newman_alpine33
entrypoint: [""]
script:
- newman --version
- npm install -g newman-reporter-htmlextra
- newman run collection.json -e environment.json --reporters cli,htmlextra --reporter-htmlextra-export testReport.html
artifacts:
when: always
paths:
- testReport.html

我确实拥有的一件事是 entrypoint: [""]image block 中。

关于docker - Newman 报告生成在本地工作,但不是来自 CI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58938634/

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