首页 > 解决方案 > Newman Docker 找不到 env 文件

问题描述

目前在我的管道的自动化阶段,我看到了以下错误:

newman 运行集合/something.postman_collection.json -k

错误:ENOENT:没有这样的文件或目录,打开 'collections/something.postman_collection.json'

来自管道的代码

代码:

阶段(“自动化”){

node('build') {

def collectionName = 'collections/something.postman_collection.json'

def postmanEnvName ='collections/somethingapi.postman_environment.json'

def globalsname = 'collections/somethingglobals.postman_globals.json'

docker.image('postman/newman_alpine33').inside("--entrypoint=''"){
   sh "newman run $collectionName -k" 
} } }

关于可能是什么问题的任何想法,我尝试了一些不同的组合,例如

“纽曼运行 $collectionName”

“纽曼 $collectionName”

“newman /collections:/etc/newman 运行 $collectionName”

docker.image('postman/newman_alpine33').inside("--entrypoint='' -v /collections:/etc/newman")

谢谢!

标签: dockerpostmannewman

解决方案


我认为您的构建服务器没有您尝试访问的文件或文件夹。您可能已经知道-v /collections:/etc/newman将主机文件夹/collections安装到您的 docker 映像的 location :/etc/newman

在您的情况下,我很确定在根目录下有文件夹collections,请检查您在哪里复制您的收藏文件。您还可以使用 npm 模块运行和测试您的集合newman。实际上,这就是您在运行 docker 映像时发生的情况。对于 ref 这里是Dockerfile


推荐阅读