Postman CLI generate a report to display in Azure CI/CD

I’m currently looking for a way to run our collections in our Azure CI/CD without the use of newman and just utilizing the new Postman CLI.

What I have so far was a sequence of task which does the following:
→ Install Postman CLI to the agent
→ Run “postman collection run <collection_hash_code> -e <env_hash_code>”

I tried looking into the parameters of postman collection run and it doesn’t seem to have a way to generate an xml or a json file of the run locally?

It does give a URL at the end of the run where you can view the results. It there a possible way to display the results in test tab in Azure CI/CD?
Thanks you. Sorry this might be a newb question. I’m still getting familiar with Azure.

Hello friend,

I believe you have to use newman. I don’t think the Postman CLI outputs their test run results to an xml file. However, I figured out how to use the collections and integrate it with my Azure DevOps pipeline.

First, you need to create a pipeline variable called POSTMAN_API_KEY and set the value to your Postman Account’s API Key.

Next, add these Azure DevOps tasks to your Azure DevOps job that is running your tests. I am running these steps on a Linux machine. If you run this on a Windows agent, you might need to change how to install newman.

- task: CmdLine@2
  displayName: 'Install newman'
  inputs:
    script: 'npm install -g newman'

- task: CmdLine@2
  displayName: 'Run automated API tests using newman CLI'
  inputs:
    script: |
        newman run https://api.getpostman.com/collections/<collection_hash_code>?apikey=$(POSTMAN_API_KEY) \
          --environment https://api.getpostman.com/environments/<env_hash_code>?apikey=$(POSTMAN_API_KEY) \
          --reporters cli,junit \
          --reporter-junit-export $(Build.SourcesDirectory)/TestResults/testResults.xml
        
- task: PublishTestResults@2
  displayName: 'Publish API test results'
  inputs:
    testResultsFiles: '$(Build.SourcesDirectory)/TestResults/*.xml'

After you run these steps you should be able to see the results in your pipeline.