Термин «newman» не распознается как имя командлета,

Я могу без проблем выполнять команды newman из обычного powershell:

введите здесь описание изображения

Однако, когда Дженкинс запускает тот же скрипт, я получаю следующий вывод:

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" не распознается как имя командлета

Что я делаю не так? Как заставить его видеть newman?


person Alex Gordon    schedule 19.04.2018    source источник


Ответы (2)


Что бы ни запускало Jenkins, похоже, что newman не находится на его пути. В контексте учетной записи службы Jenkin попробуйте where.exe newman. Если он находится в пути, он должен вернуть местоположение программы.

person Adam    schedule 19.04.2018
comment
См. ответ на этот вопрос: superuser.com/questions/737542/ - person Adam; 19.04.2018

Вы должны установить https://www.npmjs.com/package/newman

npm install -g newman

позвоните в свою коллекцию: Newman запустите examples/sample-collection.json

или используйте newman в качестве библиотеки:

const newman = require('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!');
});
person Rudson Rodrigues    schedule 01.06.2020