0
votes

I am using the task "Newman the cli Companion for Postman" (Link) in a YAML pipeline to run Postman collections for testing and warm up purposes.

I use the task like the following:

- task: carlowahlstedt.NewmanPostman.NewmanPostman.NewmanPostman@4
  displayName: 'Newman - Postman'
  inputs:
    collectionFileSource: '$(Pipeline.Workspace)/drop/Postman'
    Contents: '**\*_collection.json'
    folder: Release
    environment: '$(Pipeline.Workspace)/drop/Postman/$(Environment).postman_environment.json'
    ignoreRedirect: false
    bail: false
    sslInsecure: false
    reporters: 'html,junit'
    reporterHtmlExport: '$(Pipeline.Workspace)/drop/Postman'
    htmlExtraDarkTheme: false
    htmlExtraLogs: false
    htmlExtraTestPaging: false
    reporterJUnitExport: '$(Pipeline.Workspace)/drop/Postman'

Doing so on a hosted agent works fine but when working with a self-hosted one I get:

##[error]Unable to locate executable file: 'newman'. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.

I have newman as well as newman-reporter-html installed on the agent and am able to run it when logged in to the agent.

How can I resolve this issue?

1
"I have newman as well as newman-reporter-html installed on the agent and am able to run it when logged in to the agent." I assume you mean your self-hosted agent in the sentence above. What command did you use to install newman?Ben
npm install -g newman and npm install -g newman-reporter-htmlquervernetzt

1 Answers

1
votes

To resolve the issue I added

pathToNewman: 'C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\newman.cmd'

to the task definition. The path is used if no version is found by the agent.

As a result the task looks then like

- task: carlowahlstedt.NewmanPostman.NewmanPostman.NewmanPostman@4
  displayName: 'Newman - Postman'
  inputs:
    collectionFileSource: '$(Pipeline.Workspace)/drop/Postman'
    Contents: '**\*_collection.json'
    folder: Release
    environment: '$(Pipeline.Workspace)/drop/Postman/$(Environment).postman_environment.json'
    pathToNewman: 'C:\Windows\ServiceProfiles\NetworkService\AppData\Roaming\npm\newman.cmd'
    ignoreRedirect: false
    bail: false
    sslInsecure: false
    reporters: 'html,junit'
    reporterHtmlExport: '$(Pipeline.Workspace)/drop/Postman'
    htmlExtraDarkTheme: false
    htmlExtraLogs: false
    htmlExtraTestPaging: false
    reporterJUnitExport: '$(Pipeline.Workspace)/drop/Postman'

I am not sure why it is not finding the installed version itself. So if somebody has an idea it would be great to share.