【问题标题】:The term 'newman' is not recognized as the name of a cmdlet,术语“newman”未被识别为 cmdlet 的名称,
【发布时间】:2018-09-30 09:58:22
【问题描述】:

我可以毫无问题地从常规 powershell 执行 newman 命令:

但是,当我让 Jenkins 运行相同的脚本时,我会得到以下输出:

Checkinig prerequisites
   Chocolatey is already installed
   NodeJS is already installed
   NPM is already installed
Starting collection tests

  Testing  C:\Program Files (x86)\Jenkins\workspace\GenericServiceWithPostman\Collections\Account Recv Microservice.postman_collection.json
newman : The term 'newman' is not recognized as the name of a cmdlet, 
function, script file, or operable program. Check the spelling of the name, or 
if a path was included, verify that the path is correct and try again.
At C:\Program Files 
(x86)\Jenkins\workspace\GenericServiceWithPostman\RunColletionTests.ps1:47 
char:1
+ newman run $test.FullName --environment .\Environments\DEV01.postman_ ...
+ ~~~~~~
    + CategoryInfo          : ObjectNotFound: (newman:String) [], CommandNotFo 
   undException
    + FullyQualifiedErrorId : CommandNotFoundException

我运行的脚本:

$tests = gci .\Collections\*postman_collection.json| Select-Object -Property FullName

foreach ($test in $tests)
 { 
 Write-Host ""
Write-Host "  Testing " $test.FullName
Start-Sleep -s 5 
newman run $test.FullName --environment .\Environments\DEV01.postman_environment.json
}

“newman”一词未被识别为 cmdlet 的名称

我做错了什么?如何让它看到newman

【问题讨论】:

    标签: .net powershell jenkins postman newman


    【解决方案1】:

    你应该安装https://www.npmjs.com/package/newman

    npm install -g newman

    调用你的集合:newman run examples/sample-collection.json

    或使用 newman 作为库

    const newman = require('newman'); // 在你的项目中需要 newman

    // call newman.run to pass `options` object and wait for callback
    newman.run({
        collection: require('./sample-collection.json'),
        reporters: 'cli'
    }, function (err) {
        if (err) { throw err; }
        console.log('collection run complete!');
    });
    

    【讨论】:

      【解决方案2】:

      无论 Jenkins 运行什么,看起来 newman 都不在其路径中。在 Jenkins 的服务帐户上下文中,尝试where.exe newman。如果它在路径中,它应该返回程序的位置。

      【讨论】:

      猜你喜欢
      • 2019-10-12
      • 2017-12-11
      • 2021-12-09
      • 2020-02-25
      • 2020-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多