I’m using Jenkins to run Newman. In order for the job to finish without exiting in the middle due to a failure, I’m running newman in a try-catch in bash as the following example:
newman run collection.json || rc=$?; echo $rc; failure=true
The problem is, that even when there are no failures in newman, it still gets a 1 return code. So in my job, the following command:
newman run collection.json --reporters cli,htmlextra,junit --reporter-htmlextra-export html/repot.html --reporter-htmlextra-logs --reporter-htmlextra-title Report-API --reporter-junit-export newman/report.xml -g newman/workspace.postman_globals.json -e newman/Master.postman_environment.json || rc=$?;if [[ $rc != 0 ]]; then echo $rc; echo "^ Return Code ^";echo "$file failed";failure=true;fi
Returned the following:
┌─────────────────────────┬─────────────────────┬────────────────────┐
│ │ executed │ failed │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ requests │ 9 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ test-scripts │ 18 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ prerequest-scripts │ 11 │ 0 │
├─────────────────────────┼─────────────────────┼────────────────────┤
│ assertions │ 16 │ 0 │
├─────────────────────────┴─────────────────────┴────────────────────┤
│ total run duration: 4.2s │
├────────────────────────────────────────────────────────────────────┤
│ total data received: 35.17kB (approx) │
├────────────────────────────────────────────────────────────────────┤
│ average response time: 372ms [min: 158ms, max: 793ms, s.d.: 191ms] │
└────────────────────────────────────────────────────────────────────┘
1
^ Return Code ^
As you can see, even though in the run there were 0 failures, Newman still returns a 1 return code.
Am I missing something? Is this a Newman issue or a Bash issue?
Thanks ahead!