Newman: not found on Linux Container (Docker) on Jenkins

Hi All - When I am running Newman on Jenkins on a Linux container, I am getting newman not found. I tried to login to container and able to run newman on Linux container and it worked fine.

However only from Jenkins I am getting the issue. On the VM also its working fine.

I tried setting up the Global variable in jenkins, but it didn’t worked.

Then I tried with complete path and changing the directory to newman. But still same issue is there.

Please review and let me know if I am missing anything.

Here is the Shell script in Jenkins Build section:-

cd /usr/local/bin/node-v12.3.1-linux-x64/lib/node_modules/newman/bin
newman run SCTSTSanityTest.postman_collection.json -e StarGate.postman_environment.json -r htmlextra --reporter-htmlextra-export reports/Newman_Test_Execution_Report.html --insecure

/tmp/ 9: /tmp/ newman: not found

Hi @aaggar1 , sorry to hear you’re having some difficulties. Can you please check out these guidelines on how to ask questions here on the forum? A clear question will go a long way to getting your problem solved, even just for readability’s sake. :slight_smile:

I’ve also moved your post here to the Open Technologies category, as it is a request for help about open source.

Done, I have made the changes

1 Like

Awesome! It’s a lot more clear now.

While I’m actually not the Newman expert by any means :sweat_smile: - hoping someone else can chime in here with actual help!

@aaggar1 Looks like newman is not installed globally and that’s why you are trying to execute it from the local install location /usr/local.....

Since you are already at the newman's /bin location you can try executing it using:
./newman.js run collection.json <...options>.

Also, check our learning center documentation on this topic:

Thanks Udit for response.

To handle [/usr/bin/env: node: No such file or directory error
I updated my dockerfile with RUN ln -s /usr/local/bin/node-v12.3.1-linux-x64/bin/node /usr/bin/node to point to node to bin.

But now I am getting below error with ./newman.js

[AutomatedAPISanity_TS06_Docker] $ /bin/sh -xe /tmp/

  • cd /usr/local/bin/node-v12.3.1-linux-x64/lib/node_modules/newman/bin
  • ./newman.js run SCTSTSanityTest.postman_collection.json -e StarGate.postman_environment.json -r htmlextra --reporter-htmlextra-export reports/Newman_Test_Execution_Report.html --insecure

error: unknown option ‘-e’

@utkarsh.maheshwari could you help out here.


@dannydainton Hi danny - Please see if you can help me. I am stuck.

Hi Team - It would be great if someone could please have a look at the issue.

Hi @aaggar1,
There’s a docker image for newman you could use directly - Docker Hub. One of the examples in it looks like this

docker run -v ~/collections:/etc/postman -t postman/newman \ \
    --environment="HTTPBinNewmanTest.json.postman_environment" \
    --reporters junit --reporter-junit-export="newman-report.xml"

Probably a stupid suggestion, but can you try the environments as --environment instead of -e?

Also, in your dockerfile, if you’re already using a different base image, it might be difficult for you to use the newman docker image. But I just found that dockerfiles can now have multistage builds, so you can have multiple froms - Use multi-stage builds | Docker Documentation. Using the newman image directly, should definitely be cleaner :thinking:

Let me know if any of this helps. Apologies for such a late response!