Термин "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
?
1 ответ
Независимо от того, что работает Дженкинс, похоже newman
не на своем пути. В контексте учетной записи службы Jenkin попробуйте where.exe newman
, Если он находится в пути, он должен вернуть местоположение программы.
Вам необходимо установить 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!');
});