首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Newman htmlextra记者抱怨newman失踪但已安装

Newman htmlextra记者抱怨newman失踪但已安装
EN

Stack Overflow用户
提问于 2020-12-22 03:40:08
回答 1查看 1.4K关注 0票数 2

我试图用HTML reporter安装和运行Postman的Newman测试集(在jenkins podTemplate容器上,带有Postman帐户中的docker图像),但它总是失败,因为找不到合适的Newman版本:

代码语言:javascript
复制
"npm WARN newman-reporter-htmlextra@1.19.6 requires a peer of newman@>=4 but none is installed. You must install peer dependencies yourself"

纽曼图像码头是“邮递员/纽曼:5.2-阿尔卑斯山”。

而Run命令是

代码语言:javascript
复制
sh "newman run tests/collection.json -r htmlextra --reporter-htmlextra-export var/reports/newman/html/index.html";

我还尝试使用( "sh“前缀是因为它在groovy script..in Jenkins中)安装:

代码语言:javascript
复制
sh "npm install -g newman@4.6.1"
sh "npm install -g newman-reporter-htmlextra"

然后执行与上面相同的运行命令。

代码语言:javascript
复制
sh "newman run tests/collection.json -r htmlextra --reporter-htmlextra-export var/reports/newman/html/index.html";

但是结果是一样的。

奇怪的是,就在我得到上面提到的错误之后- jenkinsfile执行了"newman run“命令,并成功地创建了测试报告文件:

代码语言:javascript
复制
Using htmlextra version 1.19.6
Created the htmlextra report in this location: var/reports/newman/html/index.html

但随后退出脚本/作业失败。

我遗漏了什么?有什么建议吗?

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-22 11:08:24

这是一个npm错误,https://github.com/npm/npm/issues/12905

对于newman -reporter htmlextra,newman是一个同级依赖项。

在npm中,如果依赖项和包未一起安装,则不会检测到全局包的对等依赖项

在这种情况下,您可以通过使用以下命令将其安装在一起来修复它

代码语言:javascript
复制
npm install -g newman newman-reporter-htmlextra

尝试:

代码语言:javascript
复制
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: ''
    ])
  }
}


    }
  }
}
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65398954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档