Newman postman gives error sometimes when executing from Jenkins

Hi Team
My newman postman collections tests are working fine when executing locally on my machine (mac OS). The collection tests with package.json were checked into git.
Jenkins job is pulling the tests and executing in our Jenkins box. No issues. This job is scheduled for every 30 mins.

Occasionally it fails only on Jenkins with the below exception.

Based on today’s execution the scheduled job was executed 20 times. Out of 20, 14 times that the job was completed succesfully with no issues.
6 times it failed with the below error. It is happening every day. I have been investigating. No clues so far.

Jenkins box node/npm versions

npm :6.7.0,
node : 10.15.0
newman: 4.4.1

13:30:16 npm ERR! code ELIFECYCLE
13:30:16 npm ERR! errno 1
13:30:16 npm ERR! [email protected] xxxxx-tests-stage: newman run collections/zzzz.json -e collections/xxxenv.json -r htmlextra --reporter-htmlextra-export statusdashboard.html --reporter-htmlextra-template test.hbs
13:30:16 npm ERR! Exit status 1
13:30:16 npm ERR!
13:30:16 npm ERR! Failed at the [email protected] dependent-tests-stage script.
13:30:16 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
13:30:16 Build step ‘Execute shell’ marked build as failure
13:30:16 Recording test results

package.json

{
“name”: “xxxx-yyyy-services-dasbhboard”,
“version”: “1.0.0”,
“description”: “Project for Postman tests”,
“scripts”: {
“dependent-tests-stage”: “newman run collections/zzzz.json -e collections/xxxenv.json -r htmlextra --reporter-htmlextra-export ABCD.html --reporter-htmlextra-template test.hbs”,
“dependent-tests-stage-junit”: “newman run collections/zzzz.json -e collections/xxxenv.json --reporter-junit-export results.xml --reporters cli,junit”
},
“repository”: {
“type”: “git”,
“url”: “git URL XYZ”
},
“author”: “ABCD”,
“dependencies”: {
“newman”: “^4.4.0”
},
“devDependencies”: {
“nyc”: “^11.2.1”
}
}

Thanks

@rjayaram I am not super familiar with this configuration but what comes to mind quickly for me, based on that error, is there a chance something else is running on the Jenkins box that may be using that same port?

Do you know if the previous instance of the node server shut down properly? Right off the top of my head I don’t think it is a node config issue or even an issue with your tests but something in the run environment.
This is just an educated guess really. Maybe have it execute a command to list/search for the service before and after each run to help debug it.

ps aux | grep -i XXXXX

Let us know the results, would love to keep troubleshooting this.

Thanks for the quick reply @tmccann. I am trying to understand your suggestion. Are you saying to kill existing node processes ? if so, should I replace the XXXX with the node version running?

ps aux | grep -i XXXXX

Regards.

@rjayaram Right now I am suggesting that there could be an issue with a process still running when those failed runs kick off.

To start I would want it to print out if the process is running or not before and after.
Then just let it go about its normal runs and monitor the output, this is just to see if there is some weird process still hanging around thats causing those failed runs.

Sure. what should be the value of “xxxx” as we do not know which process is causing this. Please clarify. @tmccann. Thanks.

In this specific case it would likely be a node service you are looking for. That is assuming you don’t have other node jobs running on this box.

So xxxx would be node.

Sure @tmccann. I added the above ps command in Jenkins execute shell before executing the tests. Here is the result. When I executed the same command on Jenkins box, it is not displaying any node versions.
Let me know if I have to kill this process before executing the tests. if so, please share the command.

echo ‘Raje testing the processes’
12:16:21 Raje testing the processes
12:16:21 + ps aux
12:16:21 + grep -i node
12:16:21 labuser 76143 0.0 0.0 4267932 668 ?? S 12:17PM 0:00.00 grep -i node
12:16:21 [raje_play_dep] $ /bin/sh -xe /var/folders/8q/kjd9x_ks7pb_cqc2m2sn3f2h0000gp/T/jenkins2080930658001882378.sh

@rjayaram Is this the output that you see when there is a failed run?

Hi @tmccann
Sorry for the delay. The above one was not from a failed run. I am still getting the above " npm ERR! code ELIFECYCLE occasionally (This job is scheduled to execute every 30 mins, and getting this error at least twice in a day). I will update this thread with the value that I get for failed execution. Do I need to kill this process every time even if it is not failing. Here is what I have added in Jenkins:

ps aux | grep -i node
ps aux | grep -i npm
labuser 38226 0.0 0.0 4267972 712 ?? S 1:24PM 0:00.00 grep -i node
labuser 38221 0.0 0.0 4267972 712 ?? S 1:24PM 0:00.00 grep -i npm

Thanks, Rjayaram

I wouldn’t think you need to kill the process if it’s not actually running.
However you can issue the command anyway because worst case, there is nothing to kill :slight_smile:

This is all troubleshooting right now anyway to get a better idea of whats happening and to the root of why it’s failing for you.