- Install npm
sudo apt install npm
- Install Newman Runner globally
npm install -g newman
- Check postman scripts
newman run [collection.json] -e [env.json]
- Download Jenkins war file from here
- Run jenkins
java -jar jenkins.war
- Go to Jenkins Portal: http://localhost:8080
- Create new Job
- Select Freestyle Project and click ok
- Add a build step and select bash shell command
- Paste it
newman run [collection.json] -e [env.json] --suppress-exit-code 1
- Click Save
- Finally click Build Now option
https://learning.postman.com/docs/running-collections/using-newman-cli/integration-with-jenkins/
#!/bin/bash
java -jar jenkins.war
- CLI Command: sh [filename.sh] [collection.json] [env.json]
collection_Json=$1
env_Json=$2
report_name="Automate Postman Test Reporting"
# get docker image
docker pull postman/newmain
# create newman container instance, run postman collection and get test report
docker run -v ~/postman:/etc/newman --entrypoint /bin/sh -t postman/newman -c "npm install -g newman-reporter-htmlextra;newman run $collection_Json -e $env_Json -r htmlextra --reporter-htmlextra-title '$report_name' "
# run server to see report
python -m http.server 8080