gpt4 book ai didi

docker - Newman htmlextra 记者提示 Newman 丢失但已安装

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

我正在尝试使用 HTML 报告器安装和运行 Postman 的 Newman 测试集合(在带有来自 Postman 帐户的 docker 图像的 jenkins podTemplate 容器上)但它一直失败,因为找不到合适的 Newman 版本:

"npm WARN newman-reporter-htmlextra@1.19.6 requires a peer of newman@>=4 but none is installed. You must install peer dependencies yourself"
Newman 图像 docker 是“ postman / Newman :5.2- Alpine ”。
而运行命令是
sh "newman run tests/collection.json -r htmlextra --reporter-htmlextra-export var/reports/newman/html/index.html";
我也尝试安装(“sh”前缀是因为它在 groovy 脚本中..在 Jenkins 中):
sh "npm install -g newman@4.6.1"
sh "npm install -g newman-reporter-htmlextra"
然后执行与上面相同的运行命令。
sh "newman run tests/collection.json -r htmlextra --reporter-htmlextra-export var/reports/newman/html/index.html";
但结果是一样的。
奇怪的是,在我收到上面提到的错误之后 - jenkinsfile 执行“newman run”命令并成功创建测试报告文件:
Using htmlextra version 1.19.6
Created the htmlextra report in this location: var/reports/newman/html/index.html
但随后以 FAILURE 退出脚本/作业。
我错过了什么?
有什么建议吗?
谢谢!

最佳答案

那是一个 npm 错误,https://github.com/npm/npm/issues/12905
对于 newman-reporter-htmlextra , newman 是对等依赖项。
在 npm 中,如果依赖项和包没有一起安装,则不会检测到全局包的对等依赖项
在这种情况下,您可以通过使用将其安装在一起来修复它

npm install -g newman newman-reporter-htmlextra
尝试 :
podTemplate(label: "newmanPodHtmlExtra", containers: [
containerTemplate(name: "newman", image: "dannydainton/htmlextra", command: "cat", ttyEnabled: true),
]) {
node("newmanPodHtmlExtra") {
def testsFolder = "./tests";
container("newman") {

stage("Checkout") {
checkout scm;
}

try{
stage("Install & run Newman") {
sh "npm install -g newman newman-reporter-htmlextra";
sh "newman run ${testsFolder}/collection.json -r htmlextra --reporter-htmlextra-export var/reports/newman/html/index.html";
}
}catch(e){}finally{

stage("Show tests results") {
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'var/reports/newman/html', reportFiles: 'index.html', reportName: 'API Tests', reportTitles: ''
])
}
}


}
}
}

关于docker - Newman htmlextra 记者提示 Newman 丢失但已安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65398954/

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