Reputation: 60721
I'm able to execute newman
commands from regular powershell without issue:
However, when I have Jenkins run the same script, I get the following output:
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
The script that I run:
$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
}
The term 'newman' is not recognized as the name of a cmdlet
What am I doing wrong? How do I get it to see newman
?
Upvotes: 0
Views: 4275
Reputation: 345
You should to install https://www.npmjs.com/package/newman
npm install -g newman
call your collection: newman run examples/sample-collection.json
or use newman as library:
const newman = require('newman'); // require newman in your project
// 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!');
});
Upvotes: 0
Reputation: 4168
Whatever is running Jenkins, it looks like newman
isn't in its path. Under Jenkin's service account context, try where.exe newman
. If it's in the path, it should return the program's location.
Upvotes: 2